Apply fix for CVE-2008-2371 to fix a heap-based buffer overflow.
[glib.git] / glib / gdataset.h
blob2733ffb0335524db02c62c170b0f041f65f45e50
1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GLib Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GLib at ftp://ftp.gtk.org/pub/gtk/.
27 #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
28 #error "Only <glib.h> can be included directly."
29 #endif
31 #ifndef __G_DATASET_H__
32 #define __G_DATASET_H__
34 #include <glib/gquark.h>
36 G_BEGIN_DECLS
38 typedef struct _GData GData;
40 typedef void (*GDataForeachFunc) (GQuark key_id,
41 gpointer data,
42 gpointer user_data);
44 /* Keyed Data List
46 void g_datalist_init (GData **datalist);
47 void g_datalist_clear (GData **datalist);
48 gpointer g_datalist_id_get_data (GData **datalist,
49 GQuark key_id);
50 void g_datalist_id_set_data_full (GData **datalist,
51 GQuark key_id,
52 gpointer data,
53 GDestroyNotify destroy_func);
54 gpointer g_datalist_id_remove_no_notify (GData **datalist,
55 GQuark key_id);
56 void g_datalist_foreach (GData **datalist,
57 GDataForeachFunc func,
58 gpointer user_data);
60 /**
61 * G_DATALIST_FLAGS_MASK:
63 * A bitmask that restricts the possible flags passed to
64 * g_datalist_set_flags(). Passing a flags value where
65 * flags & ~G_DATALIST_FLAGS_MASK != 0 is an error.
67 #define G_DATALIST_FLAGS_MASK 0x3
69 void g_datalist_set_flags (GData **datalist,
70 guint flags);
71 void g_datalist_unset_flags (GData **datalist,
72 guint flags);
73 guint g_datalist_get_flags (GData **datalist);
75 #define g_datalist_id_set_data(dl, q, d) \
76 g_datalist_id_set_data_full ((dl), (q), (d), NULL)
77 #define g_datalist_id_remove_data(dl, q) \
78 g_datalist_id_set_data ((dl), (q), NULL)
79 #define g_datalist_get_data(dl, k) \
80 (g_datalist_id_get_data ((dl), g_quark_try_string (k)))
81 #define g_datalist_set_data_full(dl, k, d, f) \
82 g_datalist_id_set_data_full ((dl), g_quark_from_string (k), (d), (f))
83 #define g_datalist_remove_no_notify(dl, k) \
84 g_datalist_id_remove_no_notify ((dl), g_quark_try_string (k))
85 #define g_datalist_set_data(dl, k, d) \
86 g_datalist_set_data_full ((dl), (k), (d), NULL)
87 #define g_datalist_remove_data(dl, k) \
88 g_datalist_id_set_data ((dl), g_quark_try_string (k), NULL)
91 /* Location Associated Keyed Data
93 void g_dataset_destroy (gconstpointer dataset_location);
94 gpointer g_dataset_id_get_data (gconstpointer dataset_location,
95 GQuark key_id);
96 void g_dataset_id_set_data_full (gconstpointer dataset_location,
97 GQuark key_id,
98 gpointer data,
99 GDestroyNotify destroy_func);
100 gpointer g_dataset_id_remove_no_notify (gconstpointer dataset_location,
101 GQuark key_id);
102 void g_dataset_foreach (gconstpointer dataset_location,
103 GDataForeachFunc func,
104 gpointer user_data);
105 #define g_dataset_id_set_data(l, k, d) \
106 g_dataset_id_set_data_full ((l), (k), (d), NULL)
107 #define g_dataset_id_remove_data(l, k) \
108 g_dataset_id_set_data ((l), (k), NULL)
109 #define g_dataset_get_data(l, k) \
110 (g_dataset_id_get_data ((l), g_quark_try_string (k)))
111 #define g_dataset_set_data_full(l, k, d, f) \
112 g_dataset_id_set_data_full ((l), g_quark_from_string (k), (d), (f))
113 #define g_dataset_remove_no_notify(l, k) \
114 g_dataset_id_remove_no_notify ((l), g_quark_try_string (k))
115 #define g_dataset_set_data(l, k, d) \
116 g_dataset_set_data_full ((l), (k), (d), NULL)
117 #define g_dataset_remove_data(l, k) \
118 g_dataset_id_set_data ((l), g_quark_try_string (k), NULL)
120 G_END_DECLS
122 #endif /* __G_DATASET_H__ */