HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / wmem / wmem_user_cb.h
blobe9e5664c2594c0cd167b405d6fb85bc5f33cab76
1 /* wmem_user_cb.h
2 * Definitions for the Wireshark Memory Manager User Callbacks
3 * Copyright 2012, Evan Huus <eapache@gmail.com>
5 * $Id$
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__
29 #include <glib.h>
31 #ifdef __cplusplus
32 extern "C" {
33 #endif /* __cplusplus */
35 /** @addtogroup wmem
36 * @{
37 * @defgroup wmem-user-cb User Callbacks
39 * User callbacks.
41 * @{
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() */
48 } wmem_cb_event_t;
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().
72 WS_DLL_PUBLIC
73 guint
74 wmem_register_callback(wmem_allocator_t *allocator, wmem_user_cb_t callback,
75 void *user_data);
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().
82 WS_DLL_PUBLIC
83 void
84 wmem_unregister_callback(wmem_allocator_t *allocator, guint id);
86 /** @}
87 * @} */
89 #ifdef __cplusplus
91 #endif /* __cplusplus */
93 #endif /* __WMEM_USER_CB_H__ */
96 * Editor modelines - http://www.wireshark.org/tools/modelines.html
98 * Local variables:
99 * c-basic-offset: 4
100 * tab-width: 8
101 * indent-tabs-mode: nil
102 * End:
104 * vi: set shiftwidth=4 tabstop=8 expandtab:
105 * :indentSize=4:tabSize=8:noTabs=true: