aboutsummaryrefslogtreecommitdiffstats
path: root/epan/range.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2005-09-01 19:05:00 +0000
committerRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2005-09-01 19:05:00 +0000
commitb177f170eb48b67aa16b1e469f9a58f7209eaf28 (patch)
tree9a10d3de6f39eec69a8e937809be1e8acab92fd9 /epan/range.c
parent0ab779b04cc07ba85c112a2158d6fd2d7e3dc039 (diff)
convert to g_snprintf()
also make range_convert_range() return an emem allocated string svn path=/trunk/; revision=15660
Diffstat (limited to 'epan/range.c')
-rw-r--r--epan/range.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/epan/range.c b/epan/range.c
index 0c09626061..52af5540af 100644
--- a/epan/range.c
+++ b/epan/range.c
@@ -38,6 +38,7 @@
#include <epan/frame_data.h>
#include <epan/range.h>
+#include <epan/emem.h>
#include <stdio.h>
/*
@@ -294,31 +295,26 @@ range_foreach(range_t *range, void (*callback)(guint32 val))
}
}
-/* This function converts a range_t to a (g_malloc()-allocated) string. */
+/* This function converts a range_t to a (ep_alloc()-allocated) string. */
char *
range_convert_range(range_t *range)
{
- GString *str;
guint32 i;
gboolean prepend_comma = FALSE;
- char *string;
+ char *string, *str;
- str = g_string_new("");
+ string=ep_alloc(128);
+ string[0]=0;
+ str=string;
for (i=0; i < range->nranges; i++) {
- if (prepend_comma)
- g_string_append_c(str, ',');
-
if (range->ranges[i].low == range->ranges[i].high)
- g_string_sprintfa(str, "%u", range->ranges[i].low);
+ str += g_snprintf(str, 128-(str-string), "%s%u", prepend_comma?",":"", range->ranges[i].low);
else
- g_string_sprintfa(str, "%u-%u", range->ranges[i].low,
- range->ranges[i].high);
+ str += g_snprintf(str, 128-(str-string), "%s%u-%u", prepend_comma?",":"", range->ranges[i].low, range->ranges[i].high);
prepend_comma = TRUE;
}
- string = str->str;
- g_string_free(str, FALSE);
return string;
}