2 * Definitions for the Wireshark Memory Manager User Callbacks
3 * Copyright 2012, Evan Huus <eapache@gmail.com>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #ifndef __WMEM_USER_CB_H__
27 #define __WMEM_USER_CB_H__
33 #endif /* __cplusplus */
37 * @defgroup wmem-user-cb User Callbacks
44 /** The events that can trigger a callback. */
45 typedef enum _wmem_cb_event_t
{
46 WMEM_CB_FREE_EVENT
, /**< wmem_free_all() */
47 WMEM_CB_DESTROY_EVENT
/**< wmem_destroy_allocator() */
50 /** Function signature for registered user callbacks.
52 * allocator The allocator that triggered this callback.
53 * event The event type that triggered this callback.
54 * user_data Whatever user_data was originally passed to the call to
55 * wmem_register_cleanup_callback().
56 * @return FALSE to unregister the callback, TRUE otherwise.
58 typedef gboolean (*wmem_user_cb_t
) (wmem_allocator_t
*, wmem_cb_event_t
, void*);
60 /** Register a callback function with the given allocator pool.
62 * @param allocator The allocator with which to register the callback.
63 * @param callback The function to be called as the callback.
64 * @param user_data An arbitrary data pointer that is passed to the callback as
65 * a way to specify extra parameters or store extra data. Note
66 * that this pointer is not freed when a callback is finished,
67 * you have to do that yourself in the callback, or just
68 * allocate it in the appropriate wmem pool.
69 * @return ID of this callback that can be passed back to
70 * wmem_unregister_callback().
74 wmem_register_callback(wmem_allocator_t
*allocator
, wmem_user_cb_t callback
,
77 /** Unregister the callback function with the given ID.
79 * @param allocator The allocator from which to unregister the callback.
80 * @param id The callback id as returned from wmem_register_callback().
84 wmem_unregister_callback(wmem_allocator_t
*allocator
, guint id
);
91 #endif /* __cplusplus */
93 #endif /* __WMEM_USER_CB_H__ */
96 * Editor modelines - http://www.wireshark.org/tools/modelines.html
101 * indent-tabs-mode: nil
104 * vi: set shiftwidth=4 tabstop=8 expandtab:
105 * :indentSize=4:tabSize=8:noTabs=true: