Remove some extra allocations

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
Sebastian Ramacher 2015-11-11 21:26:56 +01:00
parent 2695a53bfc
commit 229ff0ad9a

View file

@ -195,9 +195,7 @@ zathura_get_version_string(zathura_t* zathura, bool markup)
GString* string = g_string_new(NULL);
/* zathura version */
char* zathura_version = g_strdup_printf("zathura %d.%d.%d", ZATHURA_VERSION_MAJOR, ZATHURA_VERSION_MINOR, ZATHURA_VERSION_REV);
g_string_append(string, zathura_version);
g_free(zathura_version);
g_string_append_printf(string, "zathura %d.%d.%d", ZATHURA_VERSION_MAJOR, ZATHURA_VERSION_MINOR, ZATHURA_VERSION_REV);
const char* format = (markup == true) ? "\n<i>(plugin)</i> %s (%d.%d.%d) <i>(%s)</i>" : "\n(plugin) %s (%d.%d.%d) (%s)";
@ -207,15 +205,12 @@ zathura_get_version_string(zathura_t* zathura, bool markup)
GIRARA_LIST_FOREACH(plugins, zathura_plugin_t*, iter, plugin) {
char* name = zathura_plugin_get_name(plugin);
zathura_plugin_version_t version = zathura_plugin_get_version(plugin);
char* text = g_strdup_printf(format,
(name == NULL) ? "-" : name,
version.major,
version.minor,
version.rev,
zathura_plugin_get_path(plugin)
);
g_string_append(string, text);
g_free(text);
g_string_append_printf(string, format,
(name == NULL) ? "-" : name,
version.major,
version.minor,
version.rev,
zathura_plugin_get_path(plugin));
} GIRARA_LIST_FOREACH_END(plugins, zathura_plugin_t*, iter, plugin);
}