diff --git a/include/lighttpd/utils.h b/include/lighttpd/utils.h index 2fe24fa..42aff1a 100644 --- a/include/lighttpd/utils.h +++ b/include/lighttpd/utils.h @@ -66,7 +66,7 @@ LI_API GString *l_g_string_assign_len(GString *string, const gchar *val, gssize LI_API gboolean l_g_string_prefix(GString *str, const gchar *s, gsize len); LI_API gboolean l_g_string_suffix(GString *str, const gchar *s, gsize len); -LI_API GString *l_g_string_from_int(GString *dest, gint64 val); +LI_API void l_g_string_append_int(GString *dest, gint64 val); LI_API gsize dirent_buf_size(DIR * dirp); diff --git a/src/utils.c b/src/utils.c index 18a97cc..9ceec91 100644 --- a/src/utils.c +++ b/src/utils.c @@ -580,19 +580,14 @@ GString *l_g_string_assign_len(GString *string, const gchar *val, gssize len) { return string; } -GString *l_g_string_from_int(GString *dest, gint64 v) { +void l_g_string_append_int(GString *dest, gint64 v) { gchar *buf, *end, swap; guint len; guint64 val; - if (!dest) { - dest = g_string_sized_new(21); - } else { - g_string_set_size(dest, 21); - } - - len = 1; - buf = dest->str; + buf = dest->str + dest->len; + len = dest->len + 1; + g_string_set_size(dest, dest->len + 21); if (v < 0) { len++; @@ -622,7 +617,6 @@ GString *l_g_string_from_int(GString *dest, gint64 v) { } dest->len = len; - return dest; } /* http://womble.decadentplace.org.uk/readdir_r-advisory.html */