Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / wsutil / wmem / wmem_user_cb.h
blob7d2a37e396a7a4a9ec2c24d0bcd03a7f6e9646c8
1 /** @file
2 * Definitions for the Wireshark Memory Manager User Callbacks
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_USER_CB_H__
13 #define __WMEM_USER_CB_H__
15 #include <glib.h>
17 #ifdef __cplusplus
18 extern "C" {
19 #endif /* __cplusplus */
21 /** @addtogroup wmem
22 * @{
23 * @defgroup wmem-user-cb User Callbacks
25 * User callbacks.
27 * @{
30 /** The events that can trigger a callback. */
31 typedef enum _wmem_cb_event_t {
32 WMEM_CB_FREE_EVENT, /**< wmem_free_all() */
33 WMEM_CB_DESTROY_EVENT /**< wmem_destroy_allocator() */
34 } wmem_cb_event_t;
36 /** Function signature for registered user callbacks.
38 * allocator The allocator that triggered this callback.
39 * event The event type that triggered this callback.
40 * user_data Whatever user_data was originally passed to the call to
41 * wmem_register_callback().
42 * @return false to unregister the callback, true otherwise.
44 typedef bool (*wmem_user_cb_t) (wmem_allocator_t*, wmem_cb_event_t, void*);
46 /** Register a callback function with the given allocator pool.
48 * @param allocator The allocator with which to register the callback.
49 * @param callback The function to be called as the callback.
50 * @param user_data An arbitrary data pointer that is passed to the callback as
51 * a way to specify extra parameters or store extra data. Note
52 * that this pointer is not freed when a callback is finished,
53 * you have to do that yourself in the callback, or just
54 * allocate it in the appropriate wmem pool.
55 * @return ID of this callback that can be passed back to
56 * wmem_unregister_callback().
58 WS_DLL_PUBLIC
59 unsigned
60 wmem_register_callback(wmem_allocator_t *allocator, wmem_user_cb_t callback,
61 void *user_data);
63 /** Unregister the callback function with the given ID.
65 * @param allocator The allocator from which to unregister the callback.
66 * @param id The callback id as returned from wmem_register_callback().
68 WS_DLL_PUBLIC
69 void
70 wmem_unregister_callback(wmem_allocator_t *allocator, unsigned id);
72 /** @}
73 * @} */
75 #ifdef __cplusplus
77 #endif /* __cplusplus */
79 #endif /* __WMEM_USER_CB_H__ */
82 * Editor modelines - https://www.wireshark.org/tools/modelines.html
84 * Local variables:
85 * c-basic-offset: 4
86 * tab-width: 8
87 * indent-tabs-mode: nil
88 * End:
90 * vi: set shiftwidth=4 tabstop=8 expandtab:
91 * :indentSize=4:tabSize=8:noTabs=true: