aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2015-01-31 08:06:05 -0500
committerMichael Mann <mmann78@netscape.net>2015-02-02 12:56:32 +0000
commit6db0a358ea963dc5be6a34f58198613b320622c3 (patch)
tree950d55b5a79560a60a9bb3413fb37f58ff99a9a6 /epan
parentbdaef53e0834792064bbabf6a9f91fb0e72f7f34 (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')
-rw-r--r--epan/value_string.c28
-rw-r--r--epan/value_string.h13
2 files changed, 40 insertions, 1 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,
diff --git a/epan/value_string.h b/epan/value_string.h
index 04f17c8b0c..746225a4a7 100644
--- a/epan/value_string.h
+++ b/epan/value_string.h
@@ -29,6 +29,7 @@ extern "C" {
#include <glib.h>
#include "ws_symbol_export.h"
+#include "wmem/wmem.h"
/* VALUE TO STRING MATCHING */
@@ -118,6 +119,11 @@ G_GNUC_PRINTF(3, 0);
WS_DLL_PUBLIC
const gchar *
+val_to_str_wmem(wmem_allocator_t *scope, const guint32 val, const value_string *vs, const char *fmt)
+G_GNUC_PRINTF(4, 0);
+
+WS_DLL_PUBLIC
+const gchar *
val_to_str_const(const guint32 val, const value_string *vs, const char *unknown_str);
WS_DLL_PUBLIC
@@ -195,11 +201,16 @@ value_string_ext_free(const value_string_ext *vse);
WS_DLL_PUBLIC
const gchar *
-val_to_str_ext(const guint32 val, value_string_ext *vs, const char *fmt)
+val_to_str_ext(const guint32 val, value_string_ext *vse, const char *fmt)
G_GNUC_PRINTF(3, 0);
WS_DLL_PUBLIC
const gchar *
+val_to_str_ext_wmem(wmem_allocator_t *scope, const guint32 val, value_string_ext *vse, const char *fmt)
+G_GNUC_PRINTF(4, 0);
+
+WS_DLL_PUBLIC
+const gchar *
val_to_str_ext_const(const guint32 val, value_string_ext *vs, const char *unknown_str);
WS_DLL_PUBLIC