diff --git a/container.c b/container.c index 76c5cd1..3afbfdc 100644 --- a/container.c +++ b/container.c @@ -26,7 +26,7 @@ void str_array_dup_append(str_array *a, const char *str) { if (!a) return; - char *dup = strdup(str); + char *dup = g_strdup(str); str_array_append(a, dup); } diff --git a/dunst.c b/dunst.c index e4bcff1..8e17965 100644 --- a/dunst.c +++ b/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->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_end = is_end; } @@ -595,7 +595,7 @@ void add_notification_to_line_cache(notification *n, int max_width) if (n->dup_count > 0) { buf = g_strdup_printf("(%d) %s", n->dup_count, msg); } else { - buf = strdup(msg); + buf = g_strdup(msg); } /* print age */ @@ -1083,7 +1083,7 @@ int init_notification(notification * n, int id) 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); if (n->icon) { n->msg = string_replace("%I", basename(n->icon), n->msg); @@ -1261,7 +1261,7 @@ void init_shortcut(keyboard_shortcut * ks) return; } - char *str = strdup(ks->str); + char *str = g_strdup(ks->str); char *str_begin = str; if (str == NULL) @@ -1725,7 +1725,7 @@ void load_options(char *cmdline_config_path) sep_color = FRAME; else { sep_color = CUSTOM; - sep_custom_color_str = strdup(c); + sep_custom_color_str = g_strdup(c); } free(c); } @@ -1827,7 +1827,7 @@ void load_options(char *cmdline_config_path) initrule(r); } - r->name = strdup(cur_section); + r->name = g_strdup(cur_section); r->appname = ini_get_string(cur_section, "appname", r->appname); r->summary = ini_get_string(cur_section, "summary", r->summary); r->body = ini_get_string(cur_section, "body", r->body); diff --git a/dunst_dbus.c b/dunst_dbus.c index 28f689b..ff61855 100644 --- a/dunst_dbus.c +++ b/dunst_dbus.c @@ -1,5 +1,6 @@ /* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */ +#include #include #include "dunst.h" @@ -358,19 +359,19 @@ void notify(DBusMessage * dmsg) expires = 1; } } - n->appname = appname != NULL ? strdup(appname) : ""; - n->summary = summary != NULL ? strdup(summary) : ""; - n->body = body != NULL ? strdup(body) : ""; - n->icon = icon != NULL ? strdup(icon) : ""; + n->appname = appname != NULL ? g_strdup(appname) : ""; + n->summary = summary != NULL ? g_strdup(summary) : ""; + n->body = body != NULL ? g_strdup(body) : ""; + n->icon = icon != NULL ? g_strdup(icon) : ""; n->timeout = expires; n->progress = (progress < 0 || progress > 100) ? 0 : progress + 1; 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++) { n->color_strings[i] = NULL; } - n->color_strings[ColFG] = fgcolor == NULL ? NULL : strdup(fgcolor); - n->color_strings[ColBG] = bgcolor == NULL ? NULL : strdup(bgcolor); + n->color_strings[ColFG] = fgcolor == NULL ? NULL : g_strdup(fgcolor); + n->color_strings[ColBG] = bgcolor == NULL ? NULL : g_strdup(bgcolor); id = init_notification(n, replaces_id); if (id > 0) diff --git a/options.c b/options.c index 7ec1a08..228c5ed 100644 --- a/options.c +++ b/options.c @@ -43,7 +43,7 @@ section_t *new_section(char *name) { 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].entry_count = 0; return §ions[section_count - 1]; @@ -82,7 +82,7 @@ void add_entry(char *section_name, char *key, char *value) s->entry_count++; int len = s->entry_count; 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); } @@ -105,12 +105,12 @@ char *ini_get_string(char *section, char *key, const char *def) { char *value = get_value(section, key); if (value) - return strdup(value); + return g_strdup(value); if (def == NULL) return NULL; else - return def ? strdup(def) : NULL; + return def ? g_strdup(def) : NULL; } int ini_get_int(char *section, char *key, int def) @@ -181,9 +181,9 @@ char *clean_value(char *value) char *s; if (value[0] == '"') - s = strdup(value + 1); + s = g_strdup(value + 1); else - s = strdup(value); + s = g_strdup(value); if (s[strlen(s) - 1] == '"') s[strlen(s) - 1] = '\0'; @@ -220,7 +220,7 @@ int load_ini_file(FILE * fp) if (current_section) free(current_section); - current_section = (strdup(start + 1)); + current_section = (g_strdup(start + 1)); new_section(current_section); continue; } @@ -283,7 +283,7 @@ int cmdline_find_option(char *key) if (!key) { return -1; } - char *key1 = strdup(key); + char *key1 = g_strdup(key); char *key2 = strstr(key1, "/"); if (key2) { @@ -335,11 +335,11 @@ char *cmdline_get_string(char *key, const char *def, char *description) char *str = cmdline_get_value(key); if (str) - return strdup(str); + return g_strdup(str); if (def == NULL) return NULL; else - return strdup(def); + return g_strdup(def); } 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) { - return strdup(usage_str); + return g_strdup(usage_str); } /* vim: set ts=8 sw=8 tw=0: */ diff --git a/utils.c b/utils.c index c7b3b5f..cc50312 100644 --- a/utils.c +++ b/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) { if (!a) - return strdup(b); + return g_strdup(b); char *new; if (!sep)