strdup -> g_strdup
This commit is contained in:
		
							parent
							
								
									34714fe1f9
								
							
						
					
					
						commit
						ba09fa21f9
					
				| @ -26,7 +26,7 @@ void str_array_dup_append(str_array *a, const char *str) | |||||||
| { | { | ||||||
|         if (!a) |         if (!a) | ||||||
|                 return; |                 return; | ||||||
|         char *dup = strdup(str); |         char *dup = g_strdup(str); | ||||||
|         str_array_append(a, dup); |         str_array_append(a, dup); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										12
									
								
								dunst.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								dunst.c
									
									
									
									
									
								
							| @ -528,7 +528,7 @@ void r_line_cache_append(r_line_cache *c, const char *s, ColorSet *col, bool is_ | |||||||
| 
 | 
 | ||||||
|     c->count++; |     c->count++; | ||||||
|     c->lines[c->count-1].colors = col; |     c->lines[c->count-1].colors = col; | ||||||
|     c->lines[c->count-1].str = strdup(s); |     c->lines[c->count-1].str = g_strdup(s); | ||||||
|     c->lines[c->count-1].is_begin = is_begin; |     c->lines[c->count-1].is_begin = is_begin; | ||||||
|     c->lines[c->count-1].is_end = is_end; |     c->lines[c->count-1].is_end = is_end; | ||||||
| } | } | ||||||
| @ -595,7 +595,7 @@ void add_notification_to_line_cache(notification *n, int max_width) | |||||||
|         if (n->dup_count > 0) { |         if (n->dup_count > 0) { | ||||||
|                 buf = g_strdup_printf("(%d) %s", n->dup_count, msg); |                 buf = g_strdup_printf("(%d) %s", n->dup_count, msg); | ||||||
|         } else { |         } else { | ||||||
|                 buf = strdup(msg); |                 buf = g_strdup(msg); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         /* print age */ |         /* print age */ | ||||||
| @ -1083,7 +1083,7 @@ int init_notification(notification * n, int id) | |||||||
| 
 | 
 | ||||||
|         apply_rules(n); |         apply_rules(n); | ||||||
| 
 | 
 | ||||||
|         n->msg = string_replace("%a", n->appname, strdup(n->format)); |         n->msg = string_replace("%a", n->appname, g_strdup(n->format)); | ||||||
|         n->msg = string_replace("%s", n->summary, n->msg); |         n->msg = string_replace("%s", n->summary, n->msg); | ||||||
|         if (n->icon) { |         if (n->icon) { | ||||||
|                 n->msg = string_replace("%I", basename(n->icon), n->msg); |                 n->msg = string_replace("%I", basename(n->icon), n->msg); | ||||||
| @ -1261,7 +1261,7 @@ void init_shortcut(keyboard_shortcut * ks) | |||||||
|                 return; |                 return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         char *str = strdup(ks->str); |         char *str = g_strdup(ks->str); | ||||||
|         char *str_begin = str; |         char *str_begin = str; | ||||||
| 
 | 
 | ||||||
|         if (str == NULL) |         if (str == NULL) | ||||||
| @ -1725,7 +1725,7 @@ void load_options(char *cmdline_config_path) | |||||||
|                                 sep_color = FRAME; |                                 sep_color = FRAME; | ||||||
|                         else { |                         else { | ||||||
|                                 sep_color = CUSTOM; |                                 sep_color = CUSTOM; | ||||||
|                                 sep_custom_color_str = strdup(c); |                                 sep_custom_color_str = g_strdup(c); | ||||||
|                         } |                         } | ||||||
|                         free(c); |                         free(c); | ||||||
|                 } |                 } | ||||||
| @ -1827,7 +1827,7 @@ void load_options(char *cmdline_config_path) | |||||||
|                         initrule(r); |                         initrule(r); | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 r->name = strdup(cur_section); |                 r->name = g_strdup(cur_section); | ||||||
|                 r->appname = ini_get_string(cur_section, "appname", r->appname); |                 r->appname = ini_get_string(cur_section, "appname", r->appname); | ||||||
|                 r->summary = ini_get_string(cur_section, "summary", r->summary); |                 r->summary = ini_get_string(cur_section, "summary", r->summary); | ||||||
|                 r->body = ini_get_string(cur_section, "body", r->body); |                 r->body = ini_get_string(cur_section, "body", r->body); | ||||||
|  | |||||||
							
								
								
									
										15
									
								
								dunst_dbus.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								dunst_dbus.c
									
									
									
									
									
								
							| @ -1,5 +1,6 @@ | |||||||
| /* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */ | /* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */ | ||||||
| 
 | 
 | ||||||
|  | #include <glib.h> | ||||||
| #include <dbus/dbus.h> | #include <dbus/dbus.h> | ||||||
| 
 | 
 | ||||||
| #include "dunst.h" | #include "dunst.h" | ||||||
| @ -358,19 +359,19 @@ void notify(DBusMessage * dmsg) | |||||||
|                         expires = 1; |                         expires = 1; | ||||||
|                 } |                 } | ||||||
|         } |         } | ||||||
|         n->appname = appname != NULL ? strdup(appname) : ""; |         n->appname = appname != NULL ? g_strdup(appname) : ""; | ||||||
|         n->summary = summary != NULL ? strdup(summary) : ""; |         n->summary = summary != NULL ? g_strdup(summary) : ""; | ||||||
|         n->body = body != NULL ? strdup(body) : ""; |         n->body = body != NULL ? g_strdup(body) : ""; | ||||||
|         n->icon = icon != NULL ? strdup(icon) : ""; |         n->icon = icon != NULL ? g_strdup(icon) : ""; | ||||||
|         n->timeout = expires; |         n->timeout = expires; | ||||||
|         n->progress = (progress < 0 || progress > 100) ? 0 : progress + 1; |         n->progress = (progress < 0 || progress > 100) ? 0 : progress + 1; | ||||||
|         n->urgency = urgency; |         n->urgency = urgency; | ||||||
|         n->dbus_client = strdup(dbus_message_get_sender(dmsg)); |         n->dbus_client = g_strdup(dbus_message_get_sender(dmsg)); | ||||||
|         for (i = 0; i < ColLast; i++) { |         for (i = 0; i < ColLast; i++) { | ||||||
|                 n->color_strings[i] = NULL; |                 n->color_strings[i] = NULL; | ||||||
|         } |         } | ||||||
|         n->color_strings[ColFG] = fgcolor == NULL ? NULL : strdup(fgcolor); |         n->color_strings[ColFG] = fgcolor == NULL ? NULL : g_strdup(fgcolor); | ||||||
|         n->color_strings[ColBG] = bgcolor == NULL ? NULL : strdup(bgcolor); |         n->color_strings[ColBG] = bgcolor == NULL ? NULL : g_strdup(bgcolor); | ||||||
| 
 | 
 | ||||||
|         id = init_notification(n, replaces_id); |         id = init_notification(n, replaces_id); | ||||||
|         if (id > 0) |         if (id > 0) | ||||||
|  | |||||||
							
								
								
									
										22
									
								
								options.c
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								options.c
									
									
									
									
									
								
							| @ -43,7 +43,7 @@ section_t *new_section(char *name) | |||||||
| { | { | ||||||
|         section_count++; |         section_count++; | ||||||
|         sections = realloc(sections, sizeof(section_t) * section_count); |         sections = realloc(sections, sizeof(section_t) * section_count); | ||||||
|         sections[section_count - 1].name = strdup(name); |         sections[section_count - 1].name = g_strdup(name); | ||||||
|         sections[section_count - 1].entries = NULL; |         sections[section_count - 1].entries = NULL; | ||||||
|         sections[section_count - 1].entry_count = 0; |         sections[section_count - 1].entry_count = 0; | ||||||
|         return §ions[section_count - 1]; |         return §ions[section_count - 1]; | ||||||
| @ -82,7 +82,7 @@ void add_entry(char *section_name, char *key, char *value) | |||||||
|         s->entry_count++; |         s->entry_count++; | ||||||
|         int len = s->entry_count; |         int len = s->entry_count; | ||||||
|         s->entries = realloc(s->entries, sizeof(entry_t) * len); |         s->entries = realloc(s->entries, sizeof(entry_t) * len); | ||||||
|         s->entries[s->entry_count - 1].key = strdup(key); |         s->entries[s->entry_count - 1].key = g_strdup(key); | ||||||
|         s->entries[s->entry_count - 1].value = clean_value(value); |         s->entries[s->entry_count - 1].value = clean_value(value); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -105,12 +105,12 @@ char *ini_get_string(char *section, char *key, const char *def) | |||||||
| { | { | ||||||
|         char *value = get_value(section, key); |         char *value = get_value(section, key); | ||||||
|         if (value) |         if (value) | ||||||
|                 return strdup(value); |                 return g_strdup(value); | ||||||
| 
 | 
 | ||||||
|         if (def == NULL) |         if (def == NULL) | ||||||
|                 return NULL; |                 return NULL; | ||||||
|         else |         else | ||||||
|                 return def ?  strdup(def) : NULL; |                 return def ?  g_strdup(def) : NULL; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int ini_get_int(char *section, char *key, int def) | int ini_get_int(char *section, char *key, int def) | ||||||
| @ -181,9 +181,9 @@ char *clean_value(char *value) | |||||||
|         char *s; |         char *s; | ||||||
| 
 | 
 | ||||||
|         if (value[0] == '"') |         if (value[0] == '"') | ||||||
|                 s = strdup(value + 1); |                 s = g_strdup(value + 1); | ||||||
|         else |         else | ||||||
|                 s = strdup(value); |                 s = g_strdup(value); | ||||||
| 
 | 
 | ||||||
|         if (s[strlen(s) - 1] == '"') |         if (s[strlen(s) - 1] == '"') | ||||||
|                 s[strlen(s) - 1] = '\0'; |                 s[strlen(s) - 1] = '\0'; | ||||||
| @ -220,7 +220,7 @@ int load_ini_file(FILE * fp) | |||||||
| 
 | 
 | ||||||
|                         if (current_section) |                         if (current_section) | ||||||
|                                 free(current_section); |                                 free(current_section); | ||||||
|                         current_section = (strdup(start + 1)); |                         current_section = (g_strdup(start + 1)); | ||||||
|                         new_section(current_section); |                         new_section(current_section); | ||||||
|                         continue; |                         continue; | ||||||
|                 } |                 } | ||||||
| @ -283,7 +283,7 @@ int cmdline_find_option(char *key) | |||||||
|         if (!key) { |         if (!key) { | ||||||
|                 return -1; |                 return -1; | ||||||
|         } |         } | ||||||
|         char *key1 = strdup(key); |         char *key1 = g_strdup(key); | ||||||
|         char *key2 = strstr(key1, "/"); |         char *key2 = strstr(key1, "/"); | ||||||
| 
 | 
 | ||||||
|         if (key2) { |         if (key2) { | ||||||
| @ -335,11 +335,11 @@ char *cmdline_get_string(char *key, const char *def, char *description) | |||||||
|         char *str = cmdline_get_value(key); |         char *str = cmdline_get_value(key); | ||||||
| 
 | 
 | ||||||
|         if (str) |         if (str) | ||||||
|                 return strdup(str); |                 return g_strdup(str); | ||||||
|         if (def == NULL) |         if (def == NULL) | ||||||
|                 return NULL; |                 return NULL; | ||||||
|         else |         else | ||||||
|                 return strdup(def); |                 return g_strdup(def); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int cmdline_get_int(char *key, int def, char *description) | int cmdline_get_int(char *key, int def, char *description) | ||||||
| @ -460,7 +460,7 @@ void cmdline_usage_append(char *key, char *type, char *description) | |||||||
| 
 | 
 | ||||||
| char *cmdline_create_usage(void) | char *cmdline_create_usage(void) | ||||||
| { | { | ||||||
|         return strdup(usage_str); |         return g_strdup(usage_str); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* vim: set ts=8 sw=8 tw=0: */ | /* vim: set ts=8 sw=8 tw=0: */ | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								utils.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								utils.c
									
									
									
									
									
								
							| @ -47,7 +47,7 @@ char *string_replace(const char *needle, const char *replacement, | |||||||
| char *string_append(char *a, const char *b, const char *sep) | char *string_append(char *a, const char *b, const char *sep) | ||||||
| { | { | ||||||
|         if (!a) |         if (!a) | ||||||
|                 return strdup(b); |                 return g_strdup(b); | ||||||
| 
 | 
 | ||||||
|         char *new; |         char *new; | ||||||
|         if (!sep) |         if (!sep) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Sascha Kruse
						Sascha Kruse