From 749ffd94d496561b269007a0fe0813d8be7df1bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Mon, 10 Oct 2016 21:07:39 +0100 Subject: [PATCH] Remove some code duplication in packet.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I60d71e0e4e7f3c35bec33910ecf4230569a1718c Reviewed-on: https://code.wireshark.org/review/18438 Reviewed-by: João Valverde --- epan/packet.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/epan/packet.c b/epan/packet.c index 50b24d7d85..28410f8e0d 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -2841,22 +2841,8 @@ dissector_handle_get_dissector_name(const dissector_handle_t handle) return handle->name; } -/* Create an anonymous handle for a new dissector. */ -dissector_handle_t -create_dissector_handle(dissector_t dissector, const int proto) -{ - struct dissector_handle *handle; - - handle = wmem_new(wmem_epan_scope(), struct dissector_handle); - handle->name = NULL; - handle->dissector = dissector; - handle->protocol = find_protocol_by_id(proto); - - return handle; -} - -dissector_handle_t create_dissector_handle_with_name(dissector_t dissector, - const int proto, const char* name) +static dissector_handle_t +new_dissector_handle(dissector_t dissector, int proto, const char *name) { struct dissector_handle *handle; @@ -2864,10 +2850,23 @@ dissector_handle_t create_dissector_handle_with_name(dissector_t dissector, handle->name = name; handle->dissector = dissector; handle->protocol = find_protocol_by_id(proto); - return handle; } +/* Create an anonymous handle for a new dissector. */ +dissector_handle_t +create_dissector_handle(dissector_t dissector, const int proto) +{ + return new_dissector_handle(dissector, proto, NULL); +} + +dissector_handle_t +create_dissector_handle_with_name(dissector_t dissector, + const int proto, const char* name) +{ + return new_dissector_handle(dissector, proto, name); +} + /* Destroy an anonymous handle for a dissector. */ static void destroy_dissector_handle(dissector_handle_t handle)