replace sasprintf with g_* equivalent
This commit is contained in:
		
							parent
							
								
									78ed4d77c5
								
							
						
					
					
						commit
						e2dc1872a7
					
				
							
								
								
									
										15
									
								
								dunst.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								dunst.c
									
									
									
									
									
								
							| @ -567,7 +567,7 @@ void add_notification_to_line_cache(notification *n, int max_width) | ||||
| 
 | ||||
|         /* print dup_count and msg*/ | ||||
|         if (n->dup_count > 0) { | ||||
|                 sasprintf(&buf, "(%d) %s", n->dup_count, msg); | ||||
|                 buf = g_strdup_printf("(%d) %s", n->dup_count, msg); | ||||
|         } else { | ||||
|                 buf = strdup(msg); | ||||
|         } | ||||
| @ -583,13 +583,13 @@ void add_notification_to_line_cache(notification *n, int max_width) | ||||
| 
 | ||||
|                 char *new_buf; | ||||
|                 if (hours > 0) { | ||||
|                         sasprintf(&new_buf, "%s (%dh %dm %ds old)", buf, hours, | ||||
|                         new_buf = g_strdup_printf("%s (%dh %dm %ds old)", buf, hours, | ||||
|                                  minutes, seconds); | ||||
|                 } else if (minutes > 0) { | ||||
|                         sasprintf(&new_buf, "%s (%dm %ds old)", buf, minutes, | ||||
|                         new_buf = g_strdup_printf("%s (%dm %ds old)", buf, minutes, | ||||
|                                  seconds); | ||||
|                 } else { | ||||
|                         sasprintf(&new_buf, "%s (%ds old)", buf, seconds); | ||||
|                         new_buf = g_strdup_printf("%s (%ds old)", buf, seconds); | ||||
|                 } | ||||
| 
 | ||||
|                 free(buf); | ||||
| @ -747,7 +747,7 @@ void fill_line_cache(int width) | ||||
|         if (indicate_hidden && queue_cnt > 0) { | ||||
|                 if (geometry.h != 1) { | ||||
|                         char *tmp; | ||||
|                         sasprintf(&tmp, "(%d more)", queue_cnt); | ||||
|                         tmp = g_strdup_printf("(%d more)", queue_cnt); | ||||
|                         ColorSet *last_colors = | ||||
|                                 line_cache.lines[line_cache.count-1].colors; | ||||
|                         r_line_cache_append(&line_cache, tmp, last_colors, true, true); | ||||
| @ -755,7 +755,7 @@ void fill_line_cache(int width) | ||||
|                 } else { | ||||
|                         char *old = line_cache.lines[0].str; | ||||
|                         char *new; | ||||
|                         sasprintf(&new, "%s (%d more)", old, queue_cnt); | ||||
|                         new = g_strdup_printf("%s (%d more)", old, queue_cnt); | ||||
|                         free(old); | ||||
|                         line_cache.lines[0].str = new; | ||||
|                 } | ||||
| @ -1147,8 +1147,7 @@ int init_notification(notification * n, int id) | ||||
|                 n_queue_enqueue(&queue, n); | ||||
|         } | ||||
| 
 | ||||
|         char *tmp; | ||||
|         sasprintf(&tmp, "%s %s", n->summary, n->body); | ||||
|         char *tmp = g_strconcat(n->summary, " ", n->body, NULL); | ||||
| 
 | ||||
|         n->urls = extract_urls(tmp); | ||||
| 
 | ||||
|  | ||||
| @ -439,18 +439,18 @@ void cmdline_usage_append(char *key, char *type, char *description) | ||||
| { | ||||
|         char *key_type; | ||||
|         if (type && strlen(type) > 0) | ||||
|                 sasprintf(&key_type, "%s (%s)", key, type); | ||||
|                 key_type = g_strdup_printf("%s (%s)", key, type); | ||||
|         else | ||||
|                 sasprintf(&key_type, "%s", key); | ||||
|                 key_type = g_strdup(key); | ||||
| 
 | ||||
|         if (!usage_str) { | ||||
|                 sasprintf(&usage_str, "%-40s - %s\n", key_type, description); | ||||
|                 usage_str = g_strdup_printf("%-40s - %s\n", key_type, description); | ||||
|                 free(key_type); | ||||
|                 return; | ||||
|         } | ||||
| 
 | ||||
|         char *tmp; | ||||
|         sasprintf(&tmp, "%s%-40s - %s\n", usage_str, key_type, description); | ||||
|         tmp = g_strdup_printf("%s%-40s - %s\n", usage_str, key_type, description); | ||||
|         free(key_type); | ||||
| 
 | ||||
|         free(usage_str); | ||||
|  | ||||
							
								
								
									
										17
									
								
								utils.c
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								utils.c
									
									
									
									
									
								
							| @ -4,6 +4,7 @@ | ||||
| #include <ctype.h> | ||||
| #include <stdlib.h> | ||||
| #include <stdio.h> | ||||
| #include <glib.h> | ||||
| 
 | ||||
| #include "utils.h" | ||||
| #include "dunst.h" | ||||
| @ -50,9 +51,9 @@ char *string_append(char *a, const char *b, const char *sep) | ||||
| 
 | ||||
|         char *new; | ||||
|         if (!sep) | ||||
|                 sasprintf(&new, "%s%s", a, b); | ||||
|                 new = g_strconcat(a,b, NULL); | ||||
|         else | ||||
|                 sasprintf(&new, "%s%s%s", a, sep, b); | ||||
|                 new = g_strconcat(a, sep, b, NULL); | ||||
|         free(a); | ||||
| 
 | ||||
|         return new; | ||||
| @ -103,16 +104,4 @@ void die(char *text, int exit_value) | ||||
|         exit(exit_value); | ||||
| } | ||||
| 
 | ||||
| int sasprintf(char **strp, const char *fmt, ...) | ||||
| { | ||||
|         va_list args; | ||||
|         int result; | ||||
| 
 | ||||
|         va_start(args, fmt); | ||||
|         if ((result = vasprintf(strp, fmt, args)) == -1) | ||||
|                 die("asprintf failed", EXIT_FAILURE); | ||||
|         va_end(args); | ||||
|         return result; | ||||
| } | ||||
| 
 | ||||
| /* vim: set ts=8 sw=8 tw=0: */ | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Sascha Kruse
						Sascha Kruse