diff options
author | Michael Mann <mmann78@netscape.net> | 2015-01-31 08:06:05 -0500 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2015-02-02 12:56:32 +0000 |
commit | 6db0a358ea963dc5be6a34f58198613b320622c3 (patch) | |
tree | 950d55b5a79560a60a9bb3413fb37f58ff99a9a6 /epan/value_string.c | |
parent | bdaef53e0834792064bbabf6a9f91fb0e72f7f34 (diff) |
Create wmem versions of val_to_str and val_to_str_ext
These will be used to replace cases where packet-scope isn't valid for val_to_str/val_to_str_ext calls
Change-Id: Ie8a4c423a8608548c837c1ae7edde52c4d728340
Reviewed-on: https://code.wireshark.org/review/6880
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/value_string.c')
-rw-r--r-- | epan/value_string.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/epan/value_string.c b/epan/value_string.c index 9cfb7af39c..e4879da69e 100644 --- a/epan/value_string.c +++ b/epan/value_string.c @@ -50,6 +50,20 @@ val_to_str(const guint32 val, const value_string *vs, const char *fmt) return ep_strdup_printf(fmt, val); } +const gchar * +val_to_str_wmem(wmem_allocator_t *scope, const guint32 val, const value_string *vs, const char *fmt) +{ + const gchar *ret; + + DISSECTOR_ASSERT(fmt != NULL); + + ret = try_val_to_str(val, vs); + if (ret != NULL) + return ret; + + return wmem_strdup_printf(scope, fmt, val); +} + /* Tries to match val against each element in the value_string array vs. Returns the associated string ptr on a match. Returns 'unknown_str', on failure. */ @@ -315,6 +329,20 @@ val_to_str_ext(const guint32 val, value_string_ext *vse, const char *fmt) return ep_strdup_printf(fmt, val); } +const gchar * +val_to_str_ext_wmem(wmem_allocator_t *scope, const guint32 val, value_string_ext *vse, const char *fmt) +{ + const gchar *ret; + + DISSECTOR_ASSERT(fmt != NULL); + + ret = try_val_to_str_ext(val, vse); + if (ret != NULL) + return ret; + + return wmem_strdup_printf(scope, fmt, val); +} + /* Like val_to_str_const for extended value strings */ const gchar * val_to_str_ext_const(const guint32 val, value_string_ext *vse, |