From 04761f220b77814bfd460da7026b61c7687f687a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Sat, 22 Oct 2016 22:33:23 +0100 Subject: Add wmem_list_find_custom() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5c4f85df0a1899d629386581de2c2c3ec0812d54 Reviewed-on: https://code.wireshark.org/review/18440 Reviewed-by: João Valverde Petri-Dish: João Valverde Reviewed-by: Evan Huus Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall --- epan/wmem/wmem_list.c | 14 ++++++++++++++ epan/wmem/wmem_list.h | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/epan/wmem/wmem_list.c b/epan/wmem/wmem_list.c index 8422ed86c9..d494b6ff1d 100644 --- a/epan/wmem/wmem_list.c +++ b/epan/wmem/wmem_list.c @@ -126,6 +126,20 @@ wmem_list_find(wmem_list_t *list, const void *data) return NULL; } +wmem_list_frame_t * +wmem_list_find_custom(wmem_list_t *list, const void *data, GCompareFunc compare_func) +{ + wmem_list_frame_t *cur; + + for (cur = list->head; cur != NULL; cur = cur->next) { + if (compare_func(cur->data, data) == 0) { + return cur; + } + } + + return NULL; +} + void wmem_list_prepend(wmem_list_t *list, void *data) { diff --git a/epan/wmem/wmem_list.h b/epan/wmem/wmem_list.h index d48b3fd74c..5b510c2977 100644 --- a/epan/wmem/wmem_list.h +++ b/epan/wmem/wmem_list.h @@ -87,6 +87,10 @@ WS_DLL_PUBLIC wmem_list_frame_t * wmem_list_find(wmem_list_t *list, const void *data); +WS_DLL_PUBLIC +wmem_list_frame_t * +wmem_list_find_custom(wmem_list_t *list, const void *data, GCompareFunc func); + WS_DLL_PUBLIC void wmem_list_prepend(wmem_list_t *list, void *data); -- cgit v1.2.3