Remove some code duplication in packet.c

Change-Id: I60d71e0e4e7f3c35bec33910ecf4230569a1718c
Reviewed-on: https://code.wireshark.org/review/18438
Reviewed-by: João Valverde <j@v6e.pt>
This commit is contained in:
João Valverde 2016-10-10 21:07:39 +01:00 committed by João Valverde
parent e226abdbb0
commit 749ffd94d4
1 changed files with 16 additions and 17 deletions

View File

@ -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)