From 8e00b10d134e4fb844cdc961e5c3230edf194b57 Mon Sep 17 00:00:00 2001 From: Robert McQueen Date: Fri, 27 Jan 2006 15:40:36 +0000 Subject: 2006-01-27 Robert McQueen * glib/dbus-gtype-specialized.[ch], glib/dbus-gvalue-utils.c: Patch by me and Rob Taylor to add a simple_free function to D-Bus map and collection types, which allows those types which can be freed with a GDestroyNotify (such as GHashTables and GArrays, but not GPtrArrays) to be stored as the values in hashtables. * test/glib/test-dbus-glib.c, test/glib/test-service-glib.{c,xml}: Patch by Rob Taylor to add nested dicts to the glib tests to check the above code works, and appears not to leak when called repeatedly. --- glib/dbus-gtype-specialized.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'glib/dbus-gtype-specialized.c') diff --git a/glib/dbus-gtype-specialized.c b/glib/dbus-gtype-specialized.c index ccf65eef..ad93a8c5 100644 --- a/glib/dbus-gtype-specialized.c +++ b/glib/dbus-gtype-specialized.c @@ -91,7 +91,15 @@ proxy_value_free (GValue *value) data = lookup_specialization_data (type); g_assert (data != NULL); - data->klass->vtable->free_func (type, value->data[0].v_pointer); + if (data->klass->vtable->free_func) + { + data->klass->vtable->free_func (type, value->data[0].v_pointer); + } + else + { + g_assert (data->klass->vtable->simple_free_func != NULL); + data->klass->vtable->simple_free_func (value->data[0].v_pointer); + } } } @@ -227,6 +235,29 @@ dbus_g_type_register_map (const char *name, register_container (name, DBUS_G_SPECTYPE_MAP, (const DBusGTypeSpecializedVtable*) vtable); } +const DBusGTypeSpecializedMapVtable* dbus_g_type_map_peek_vtable (GType map_type) +{ + DBusGTypeSpecializedData *data; + g_return_val_if_fail (dbus_g_type_is_map(map_type), NULL); + + data = lookup_specialization_data (map_type); + g_assert (data != NULL); + + return (DBusGTypeSpecializedMapVtable *)(data->klass->vtable); +} + +const DBusGTypeSpecializedCollectionVtable* dbus_g_type_collection_peek_vtable (GType collection_type) +{ + DBusGTypeSpecializedData *data; + g_return_val_if_fail (dbus_g_type_is_collection(collection_type), NULL); + + data = lookup_specialization_data (collection_type); + g_assert (data != NULL); + + return (DBusGTypeSpecializedCollectionVtable *)(data->klass->vtable); +} + + static GType register_specialized_instance (const DBusGTypeSpecializedContainer *klass, char *name, -- cgit