Skip to content

Commit

Permalink
Simplify utils_get_hex_from_color() and plug a possible memory leak i…
Browse files Browse the repository at this point in the history
…n it
  • Loading branch information
b4n committed Nov 3, 2013
1 parent fd18b74 commit 02852b3
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/utils.c
Expand Up @@ -863,16 +863,12 @@ gchar *utils_get_setting_string(GKeyFile *config, const gchar *section, const gc

gchar *utils_get_hex_from_color(GdkColor *color)
{
gchar *buffer = g_malloc0(9);

g_return_val_if_fail(color != NULL, NULL);

g_snprintf(buffer, 8, "#%02X%02X%02X",
(guint) (utils_scale_round(color->red / 256, 255)),
(guint) (utils_scale_round(color->green / 256, 255)),
(guint) (utils_scale_round(color->blue / 256, 255)));

return buffer;
return g_strdup_printf("#%02X%02X%02X",
(guint) (utils_scale_round(color->red / 256, 255)),
(guint) (utils_scale_round(color->green / 256, 255)),
(guint) (utils_scale_round(color->blue / 256, 255)));
}


Expand Down

0 comments on commit 02852b3

Please sign in to comment.