From 62676bebb7ebdc3817aa069c7f87daab9aea6b9a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Thu, 3 Jan 2013 14:05:56 +0000 Subject: [PATCH] edbus codegen: Optimizations MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use eina_strbuf_string_steal() instead of strdup() + eina_strbuf_string_get(). Patch by: José Roberto de Souza SVN revision: 82073 --- src/bin/edbus/parser.c | 2 +- src/bin/edbus/utils.c | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/bin/edbus/parser.c b/src/bin/edbus/parser.c index 55bbab8..36b1810 100644 --- a/src/bin/edbus/parser.c +++ b/src/bin/edbus/parser.c @@ -201,7 +201,7 @@ open_signal(const char *content, unsigned length, Eina_Bool is_open_empty) eina_strbuf_append_char(buf, toupper(d_signal->name[i])); } eina_strbuf_append(buf, "_EVENT"); - d_signal->signal_event = strdup(eina_strbuf_string_get(buf)); + d_signal->signal_event = eina_strbuf_string_steal(buf); eina_strbuf_free(buf); return r; diff --git a/src/bin/edbus/utils.c b/src/bin/edbus/utils.c index a7d6273..02e7fb0 100644 --- a/src/bin/edbus/utils.c +++ b/src/bin/edbus/utils.c @@ -20,7 +20,7 @@ file_read(const char *file_name, char **buffer) eina_strbuf_append_char(buf, data); fclose(xml_handler); - *buffer = strdup(eina_strbuf_string_get(buf)); + *buffer = eina_strbuf_string_steal(buf); eina_strbuf_free(buf); return EINA_TRUE; @@ -62,8 +62,7 @@ dbus_name_to_c(const char *dbus) while ((pch = strtok(NULL, "/."))) eina_strbuf_append_printf(buffer, "_%s",pch); - ret = strdup(eina_strbuf_string_get(buffer)); - eina_strbuf_reset(buffer); + ret = eina_strbuf_string_steal(buffer); for (i = 0; ret[i]; i++) { if (i > 0 && ret[i-1] != '_' && ret[i] > '@' && ret[i] < '[')//upper case @@ -72,7 +71,7 @@ dbus_name_to_c(const char *dbus) eina_strbuf_append_char(buffer, tolower(ret[i])); } free(ret); - ret = strdup(eina_strbuf_string_get(buffer)); + ret = eina_strbuf_string_steal(buffer); end: free(str_cpy); eina_strbuf_free(buffer); @@ -93,7 +92,7 @@ replace_string(const char *string, const char *substr, const char *replacement) while ((pch = strtok(NULL, substr))) eina_strbuf_append_printf(buffer, "%s%s", replacement, pch); - ret = strdup(eina_strbuf_string_get(buffer)); + ret = eina_strbuf_string_steal(buffer); free(str_cpy); eina_strbuf_free(buffer); return ret; @@ -126,7 +125,7 @@ string_build(const char *fmt, ...) eina_strbuf_prepend_vprintf(buffer, fmt, ap); va_end(ap); - ret = strdup(eina_strbuf_string_get(buffer)); + ret = eina_strbuf_string_steal(buffer); eina_strbuf_free(buffer); return ret; -- 2.7.4