aboutsummaryrefslogtreecommitdiffstats
path: root/epan/value_string.c
diff options
context:
space:
mode:
authorEvan Huus <eapache@gmail.com>2013-09-29 12:44:50 +0000
committerEvan Huus <eapache@gmail.com>2013-09-29 12:44:50 +0000
commitc1dd5d3882978b541cfb65c99b91813cbaed45ba (patch)
treea81bb59241271313fb73db4c60f8a471f2cbad62 /epan/value_string.c
parent640a45d707e1cbf0d21fffd445d770e811584628 (diff)
Replace some val_to_str calls with the equivalent val_to_str_const calls (and
implement rval_to_str_const to do this). The format-strings didn't have any parameter specifiers in them, so they were clearly never used (or they would have blown up) but still a bug. This is one of the first steps towards converting val_to_str and friends to wmem. I'm honestly not sure what the best approach is for the API in this case: the vast majority of usage is within dissectors, so just hard-coding packet scope (the way they currently hard-code ep_ scope) doesn't look terrible, but there are *some* uses in taps and other places that will need to be converted to something else if we go that route. Adding a wmem_pool parameter just for the uncommon case seems a bit like overkill, though perhaps it is the right thing to do. svn path=/trunk/; revision=52264
Diffstat (limited to 'epan/value_string.c')
-rw-r--r--epan/value_string.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/epan/value_string.c b/epan/value_string.c
index d5a11ba9c5..28abf1e71d 100644
--- a/epan/value_string.c
+++ b/epan/value_string.c
@@ -544,6 +544,22 @@ rval_to_str(const guint32 val, const range_string *rs, const char *fmt)
return ep_strdup_printf(fmt, val);
}
+/* Like val_to_str_const except for range_string */
+const gchar *
+rval_to_str_const(const guint32 val, const range_string *rs,
+ const char *unknown_str)
+{
+ const gchar *ret = NULL;
+
+ DISSECTOR_ASSERT(unknown_str != NULL);
+
+ ret = try_rval_to_str(val, rs);
+ if(ret != NULL)
+ return ret;
+
+ return unknown_str;
+}
+
/* Like try_val_to_str_idx except for range_string */
const gchar *
try_rval_to_str_idx(const guint32 val, const range_string *rs, gint *idx)