regen pidl all: rm epan/dissectors/pidl/*-stamp; pushd epan/dissectors/pidl/ && make...
[wireshark-sm.git] / wsutil / wmem / wmem_list.h
blob6b73e9925087d77341c956613288fa2daae7d722
1 /** @file
2 * Definitions for the Wireshark Memory Manager Doubly-Linked List
3 * Copyright 2012, Evan Huus <eapache@gmail.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #ifndef __WMEM_LIST_H__
13 #define __WMEM_LIST_H__
15 #include <string.h>
16 #include <glib.h>
18 #include "wmem_core.h"
20 #ifdef __cplusplus
21 extern "C" {
22 #endif /* __cplusplus */
24 /** @addtogroup wmem
25 * @{
26 * @defgroup wmem-list Doubly-Linked List
28 * A doubly-linked list implementation on top of wmem.
30 * @{
33 struct _wmem_list_t;
34 struct _wmem_list_frame_t;
36 typedef struct _wmem_list_t wmem_list_t;
37 typedef struct _wmem_list_frame_t wmem_list_frame_t;
39 WS_DLL_PUBLIC
40 unsigned
41 wmem_list_count(const wmem_list_t *list);
43 WS_DLL_PUBLIC
44 wmem_list_frame_t *
45 wmem_list_head(const wmem_list_t *list);
47 WS_DLL_PUBLIC
48 wmem_list_frame_t *
49 wmem_list_tail(const wmem_list_t *list);
51 WS_DLL_PUBLIC
52 wmem_list_frame_t *
53 wmem_list_frame_next(const wmem_list_frame_t *frame);
55 WS_DLL_PUBLIC
56 wmem_list_frame_t *
57 wmem_list_frame_prev(const wmem_list_frame_t *frame);
59 WS_DLL_PUBLIC
60 void *
61 wmem_list_frame_data(const wmem_list_frame_t *frame);
63 WS_DLL_PUBLIC
64 void
65 wmem_list_remove(wmem_list_t *list, void *data);
67 WS_DLL_PUBLIC
68 void
69 wmem_list_remove_frame(wmem_list_t *list, wmem_list_frame_t *frame);
72 * Linear search, search is O(n)
74 WS_DLL_PUBLIC
75 wmem_list_frame_t *
76 wmem_list_find(wmem_list_t *list, const void *data);
78 WS_DLL_PUBLIC
79 wmem_list_frame_t *
80 wmem_list_find_custom(wmem_list_t *list, const void *data, GCompareFunc func);
82 WS_DLL_PUBLIC
83 void
84 wmem_list_prepend(wmem_list_t *list, void *data);
86 WS_DLL_PUBLIC
87 void
88 wmem_list_append(wmem_list_t *list, void *data);
90 WS_DLL_PUBLIC
91 void
92 wmem_list_insert_sorted(wmem_list_t *list, void* data, GCompareFunc func);
95 * Appender Insertion (start search from the tail)
97 WS_DLL_PUBLIC
98 void
99 wmem_list_append_sorted(wmem_list_t *list, void* data, GCompareFunc func);
102 WS_DLL_PUBLIC
103 wmem_list_t *
104 wmem_list_new(wmem_allocator_t *allocator)
105 G_GNUC_MALLOC;
107 WS_DLL_PUBLIC
108 void
109 wmem_list_foreach(wmem_list_t *list, GFunc foreach_func, void * user_data);
111 WS_DLL_PUBLIC
112 void
113 wmem_destroy_list(wmem_list_t *list);
115 /** @}
116 * @} */
118 #ifdef __cplusplus
120 #endif /* __cplusplus */
122 #endif /* __WMEM_LIST_H__ */
125 * Editor modelines - https://www.wireshark.org/tools/modelines.html
127 * Local variables:
128 * c-basic-offset: 4
129 * tab-width: 8
130 * indent-tabs-mode: nil
131 * End:
133 * vi: set shiftwidth=4 tabstop=8 expandtab:
134 * :indentSize=4:tabSize=8:noTabs=true: