From b423170266eece11148de51649ec61d7db160a5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 17 Mar 2009 11:44:44 +0100 Subject: [PATCH] Rewrite l_g_string_from_int to l_g_string_append_int --- include/lighttpd/utils.h | 2 +- src/utils.c | 14 ++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) 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 */