diff options
author | Dario Lombardo <lomato@gmail.com> | 2016-05-03 18:40:17 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2016-06-17 15:38:03 +0000 |
commit | 2e9f3c5d366eaa7139fc877b5301392166b3f985 (patch) | |
tree | ac2d04b7cc1b8d6c8962d437584e351fcf1bf450 /epan/tap.c | |
parent | 2aa55a387a87cd4f740aea661ca1ca535cd2e392 (diff) |
tap: change glib functions to wmem.
Change-Id: I878ae6b121a669f9b7f4e1e57bc079f0cb44c0bf
Reviewed-on: https://code.wireshark.org/review/15270
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/tap.c')
-rw-r--r-- | epan/tap.c | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/epan/tap.c b/epan/tap.c index 1348e375dd..129223fc0e 100644 --- a/epan/tap.c +++ b/epan/tap.c @@ -39,6 +39,7 @@ #include <epan/packet_info.h> #include <epan/dfilter/dfilter.h> #include <epan/tap.h> +#include <epan/wmem/wmem_list.h> static gboolean tapping_is_active=FALSE; @@ -118,7 +119,7 @@ typedef struct { void (*register_tap_listener_fn)(void); /* routine to call to register tap listener */ } tap_plugin; -static GSList *tap_plugins = NULL; +static wmem_list_t *tap_plugins = NULL; /* * Callback for each plugin found. @@ -148,9 +149,9 @@ DIAG_ON(pedantic) /* * Add this one to the list of tap plugins. */ - plugin = (tap_plugin *)g_malloc(sizeof (tap_plugin)); + plugin = wmem_new(NULL, tap_plugin); plugin->register_tap_listener_fn = register_tap_listener_fn; - tap_plugins = g_slist_append(tap_plugins, plugin); + wmem_list_append(tap_plugins, plugin); return TRUE; } @@ -174,7 +175,7 @@ register_tap_plugin_listener(gpointer data, gpointer user_data _U_) void register_all_plugin_tap_listeners(void) { - g_slist_foreach(tap_plugins, register_tap_plugin_listener, NULL); + wmem_list_foreach(tap_plugins, register_tap_plugin_listener, NULL); } #endif /* HAVE_PLUGINS */ @@ -188,6 +189,7 @@ void tap_init(void) { tap_packet_index=0; + tap_plugins = wmem_list_new(NULL); } /* ********************************************************************** @@ -222,9 +224,9 @@ register_tap(const char *name) return tap_id; } - td=(tap_dissector_t *)g_malloc(sizeof(tap_dissector_t)); + td=wmem_new(NULL, tap_dissector_t); td->next=NULL; - td->name = g_strdup(name); + td->name = wmem_strdup(NULL, name); if(!tap_dissector_list){ tap_dissector_list=td; @@ -506,10 +508,8 @@ free_tap_listener(volatile tap_listener_t *tl) if(tl->code){ dfilter_free(tl->code); } - g_free(tl->fstring); -DIAG_OFF(cast-qual) - g_free((gpointer)tl); -DIAG_ON(cast-qual) + wmem_free(NULL, tl->fstring); + wmem_free(NULL, (void*)tl); } /* this function attaches the tap_listener to the named tap. @@ -518,30 +518,28 @@ DIAG_ON(cast-qual) * non-NULL: error, return value points to GString containing error * message. */ -GString * +gchar * register_tap_listener(const char *tapname, void *tapdata, const char *fstring, guint flags, tap_reset_cb reset, tap_packet_cb packet, tap_draw_cb draw) { volatile tap_listener_t *tl; int tap_id; dfilter_t *code=NULL; - GString *error_string; + gchar *error_string = NULL; gchar *err_msg; tap_id=find_tap_id(tapname); if(!tap_id){ - error_string = g_string_new(""); - g_string_printf(error_string, "Tap %s not found", tapname); + error_string = wmem_strdup_printf(NULL, "Tap %s not found", tapname); return error_string; } - tl=(volatile tap_listener_t *)g_malloc0(sizeof(tap_listener_t)); + tl=wmem_new0(NULL, volatile tap_listener_t); tl->needs_redraw=TRUE; tl->flags=flags; if(fstring){ if(!dfilter_compile(fstring, &code, &err_msg)){ - error_string = g_string_new(""); - g_string_printf(error_string, + error_string = wmem_strdup_printf(NULL, "Filter \"%s\" is invalid - %s", fstring, err_msg); g_free(err_msg); @@ -549,7 +547,7 @@ register_tap_listener(const char *tapname, void *tapdata, const char *fstring, return error_string; } } - tl->fstring=g_strdup(fstring); + tl->fstring=wmem_strdup(NULL, fstring); tl->code=code; tl->tap_id=tap_id; @@ -566,12 +564,12 @@ register_tap_listener(const char *tapname, void *tapdata, const char *fstring, /* this function sets a new dfilter to a tap listener */ -GString * +gchar * set_tap_dfilter(void *tapdata, const char *fstring) { volatile tap_listener_t *tl=NULL,*tl2; dfilter_t *code=NULL; - GString *error_string; + gchar *error_string; gchar *err_msg; if(!tap_listener_queue){ @@ -596,19 +594,19 @@ set_tap_dfilter(void *tapdata, const char *fstring) tl->code=NULL; } tl->needs_redraw=TRUE; - g_free(tl->fstring); + wmem_free(NULL, tl->fstring); if(fstring){ if(!dfilter_compile(fstring, &code, &err_msg)){ tl->fstring=NULL; - error_string = g_string_new(""); - g_string_printf(error_string, + error_string = wmem_strdup_printf( + NULL, "Filter \"%s\" is invalid - %s", fstring, err_msg); - g_free(err_msg); + wmem_free(NULL, err_msg); return error_string; } } - tl->fstring=g_strdup(fstring); + tl->fstring=wmem_strdup(NULL, fstring); tl->code=code; } |