+Sun Mar 3 04:11:58 2002 Tim Janik <timj@gtk.org>
+
+ * gobject.c: placed a comment about not changing CArray until we have
+ g_object_list_watched_closures().
+
+ * gparam.h (struct _GParamSpecClass): added padding.
+
+ * gobjectnotifyqueue.c (struct _GObjectNotifyQueue): abuse
+ g_list_alloc() to allocate GObjectNotifyQueue to et rid
+ of locking issues.
+
Tue Feb 26 10:51:00 2002 Owen Taylor <otaylor@redhat.com>
* Makefile.am (testgobject_LDADD): Rename testgruntime
static void
g_object_do_class_init (GObjectClass *class)
{
+ /* read the comment about typedef struct CArray; on why not to change this quark */
quark_closure_array = g_quark_from_static_string ("GObject-closure-array");
+
quark_weak_refs = g_quark_from_static_string ("GObject-weak-references");
pspec_pool = g_param_spec_pool_new (TRUE);
property_notify_context.quark_notify_queue = g_quark_from_static_string ("GObject-notify-queue");
guint n_closures;
GClosure *closures[1]; /* flexible array */
} CArray;
+/* don't change this structure without supplying an accessor for
+ * watched closures, e.g.:
+ * GSList* g_object_list_watched_closures (GObject *object)
+ * {
+ * CArray *carray;
+ * g_return_val_if_fail (G_IS_OBJECT (object), NULL);
+ * carray = g_object_get_data (object, "GObject-closure-array");
+ * if (carray)
+ * {
+ * GSList *slist = NULL;
+ * guint i;
+ * for (i = 0; i < carray->n_closures; i++)
+ * slist = g_slist_prepend (slist, carray->closures[i]);
+ * return slist;
+ * }
+ * return NULL;
+ * }
+ */
static void
object_remove_closure (gpointer data,
{
GQuark quark_notify_queue;
GObjectNotifyQueueDispatcher dispatcher;
- GTrashStack *nqueue_trash;
+ GTrashStack *_nqueue_trash; /* unused */
};
struct _GObjectNotifyQueue
{
GObjectNotifyContext *context;
GSList *pspecs;
- guint n_pspecs;
- guint freeze_count;
+ guint16 n_pspecs;
+ guint16 freeze_count;
+ /* currently, this structure abuses the GList allocation chain and thus
+ * must be <= sizeof (GList)
+ */
};
GObjectNotifyQueue *nqueue = data;
g_slist_free (nqueue->pspecs);
- g_trash_stack_push (&nqueue->context->nqueue_trash, nqueue);
+ g_list_free_1 ((void*) nqueue);
}
static inline GObjectNotifyQueue*
nqueue = g_datalist_id_get_data (&object->qdata, context->quark_notify_queue);
if (!nqueue)
{
- nqueue = g_trash_stack_pop (&context->nqueue_trash);
- if (!nqueue)
- {
- guint i;
-
- nqueue = g_new (GObjectNotifyQueue, 16);
- for (i = 0; i < 15; i++)
- g_trash_stack_push (&context->nqueue_trash, nqueue++);
- }
+ nqueue = (void*) g_list_alloc ();
memset (nqueue, 0, sizeof (*nqueue));
nqueue->context = context;
g_datalist_id_set_data_full (&object->qdata, context->quark_notify_queue,
nqueue, g_object_notify_queue_free);
}
+
+ g_return_val_if_fail (nqueue->freeze_count < 65535, nqueue);
nqueue->freeze_count++;
return nqueue;
{
if (pspec->flags & G_PARAM_READABLE)
{
+ g_return_if_fail (nqueue->n_pspecs < 65535);
+
/* we do the deduping in _thaw */
nqueue->pspecs = g_slist_prepend (nqueue->pspecs, pspec);
nqueue->n_pspecs++;