From: Tim Janik Date: Sun, 3 Mar 2002 03:14:43 +0000 (+0000) Subject: placed a comment about not changing CArray until we have X-Git-Tag: GLIB_2_0_0_RC1~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d7dd9aefd8409f5dae6a05f22f166d6c4f19e95f;p=platform%2Fupstream%2Fglib.git placed a comment about not changing CArray until we have Sun Mar 3 04:11:58 2002 Tim Janik * 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. --- diff --git a/gobject/ChangeLog b/gobject/ChangeLog index b1d1453..0821369 100644 --- a/gobject/ChangeLog +++ b/gobject/ChangeLog @@ -1,3 +1,14 @@ +Sun Mar 3 04:11:58 2002 Tim Janik + + * 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 * Makefile.am (testgobject_LDADD): Rename testgruntime diff --git a/gobject/gobject.c b/gobject/gobject.c index 2c05670..ebfd82c 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -233,7 +233,9 @@ g_object_notify_dispatcher (GObject *object, 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"); @@ -1593,6 +1595,24 @@ typedef struct { 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, diff --git a/gobject/gobjectnotifyqueue.c b/gobject/gobjectnotifyqueue.c index f2c0873..03db5c2 100644 --- a/gobject/gobjectnotifyqueue.c +++ b/gobject/gobjectnotifyqueue.c @@ -38,14 +38,17 @@ struct _GObjectNotifyContext { 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) + */ }; @@ -56,7 +59,7 @@ g_object_notify_queue_free (gpointer data) 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* @@ -68,20 +71,14 @@ g_object_notify_queue_freeze (GObject *object, 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; @@ -145,6 +142,8 @@ g_object_notify_queue_add (GObject *object, { 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++; diff --git a/gobject/gparam.h b/gobject/gparam.h index 7e8bb17..3fbea4b 100644 --- a/gobject/gparam.h +++ b/gobject/gparam.h @@ -98,6 +98,7 @@ struct _GParamSpecClass gint (*values_cmp) (GParamSpec *pspec, const GValue *value1, const GValue *value2); + gpointer dummy[4]; }; struct _GParameter /* auxillary structure for _setv() variants */ {