Reserving quarks
- From: Espen S Johnsen <espejohn online no>
- To: gtk-devel-list gnome org
- Subject: Reserving quarks
- Date: 19 Aug 2000 02:19:18 +0200
I am currently updating (actually rewriting) my Common Lisp bindings to
GTK for version 1.3 and was just looking into moving the user data stuff
from GtkObject to GObject when the following issue came up.
In Lisp one usually do not use strings as data keys but rather symbols
or other objects compareable with eq. So in the current implementation,
names of symbols (which are strings) used as keys get passed to
gtk_object_get/set_data. In addition to the lack of similar functions
for GObject, this has two major problems; it limits the keys to symbols
and two different symbols may have the same name (and I won't even
mention the memory overhead).
As a solution I was thinking of doing my own object to quark mapping. To
do this it would be necessary to reserve quarks from glib for this
use. Something like the function in the follwing patch would have to be
added to glib. Is that possible?
--- gdataset.c.orig Sat Aug 19 01:13:59 2000
+++ gdataset.c Sat Aug 19 01:11:55 2000
@@ -619,7 +619,21 @@
g_quarks[g_quark_seq_id] = string;
g_quark_seq_id++;
quark = g_quark_seq_id;
- g_hash_table_insert (g_quark_ht, string, GUINT_TO_POINTER (quark));
+ if (string)
+ g_hash_table_insert (g_quark_ht, string, GUINT_TO_POINTER (quark));
+
+ return quark;
+}
+
+
+GQuark
+g_quark_get_reserved (void)
+{
+ GQuark quark;
+
+ G_LOCK (g_quark_global);
+ quark = g_quark_new (NULL);
+ G_UNLOCK (g_quark_global);
return quark;
}
--
Espen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]