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__
19 #endif /* __cplusplus */
23 * @defgroup wmem-user-cb User Callbacks
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() */
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().
60 wmem_register_callback(wmem_allocator_t
*allocator
, wmem_user_cb_t callback
,
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().
70 wmem_unregister_callback(wmem_allocator_t
*allocator
, unsigned id
);
77 #endif /* __cplusplus */
79 #endif /* __WMEM_USER_CB_H__ */
82 * Editor modelines - https://www.wireshark.org/tools/modelines.html
87 * indent-tabs-mode: nil
90 * vi: set shiftwidth=4 tabstop=8 expandtab:
91 * :indentSize=4:tabSize=8:noTabs=true: