diff options
author | Matthieu Coudron <mattator@gmail.com> | 2015-12-02 23:34:53 +0100 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2015-12-04 04:00:48 +0000 |
commit | 0d3f77fff1c7c7cdcf010ace9a3ff7f7f705e7e2 (patch) | |
tree | b8ef01b138a5558e3437cbf90d9d6a1e986f501f /epan/wmem | |
parent | be04716601031fdca1884a9ced3c857812c531a7 (diff) |
Adds wmem_list_find function
Change-Id: I72162210b830a57978e108032d75d8c54f17d16b
Reviewed-on: https://code.wireshark.org/review/12387
Reviewed-by: Evan Huus <eapache@gmail.com>
Petri-Dish: Evan Huus <eapache@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/wmem')
-rw-r--r-- | epan/wmem/wmem_list.c | 13 | ||||
-rw-r--r-- | epan/wmem/wmem_list.h | 7 |
2 files changed, 20 insertions, 0 deletions
diff --git a/epan/wmem/wmem_list.c b/epan/wmem/wmem_list.c index 0f4900da3c..0d7ade8c33 100644 --- a/epan/wmem/wmem_list.c +++ b/epan/wmem/wmem_list.c @@ -113,6 +113,19 @@ wmem_list_remove_frame(wmem_list_t *list, wmem_list_frame_t *frame) wmem_free(list->allocator, frame); } +wmem_list_frame_t * +wmem_list_find(wmem_list_t *list, const void *data) +{ + wmem_list_frame_t *cur; + + for (cur = list->head; cur; cur = cur->next) { + if(cur->data == data) + 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 3e9de50508..bc4bba0811 100644 --- a/epan/wmem/wmem_list.h +++ b/epan/wmem/wmem_list.h @@ -80,6 +80,13 @@ WS_DLL_PUBLIC void wmem_list_remove_frame(wmem_list_t *list, wmem_list_frame_t *frame); +/* + * Linear search, search is O(n) + */ +WS_DLL_PUBLIC +wmem_list_frame_t * +wmem_list_find(wmem_list_t *list, const void *data); + WS_DLL_PUBLIC void wmem_list_prepend(wmem_list_t *list, void *data); |