diff options
author | Alexander Larsson <alexl@src.gnome.org> | 2007-09-13 11:13:23 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2007-09-13 11:13:23 +0000 |
commit | 3c9f59e9bb4e28eb1534976c34300e3854bc0925 (patch) | |
tree | 844c7589031462cc47d1a40535797e5aecdd4152 /common/gmountspec.c | |
parent | 6222ed3e656389695f8031d62bb401628d1c8edd (diff) | |
download | gvfs-3c9f59e9bb4e28eb1534976c34300e3854bc0925.tar.gz |
Make GMountSpec refcounted
Original git commit by Alexander Larsson <alex@greebo.(none)> at 1170078223 +0100
svn path=/trunk/; revision=275
Diffstat (limited to 'common/gmountspec.c')
-rw-r--r-- | common/gmountspec.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/common/gmountspec.c b/common/gmountspec.c index 0e8170e0..32d9327a 100644 --- a/common/gmountspec.c +++ b/common/gmountspec.c @@ -51,22 +51,32 @@ g_mount_spec_add_item (GMountSpec *spec, g_array_sort (spec->items, item_compare); } +GMountSpec * +g_mount_spec_ref (GMountSpec *spec) +{ + g_atomic_int_inc (&spec->ref_count); + return spec; +} + void -g_mount_spec_free (GMountSpec *spec) +g_mount_spec_unref (GMountSpec *spec) { int i; - - g_free (spec->mount_prefix); - for (i = 0; i < spec->items->len; i++) + + if (g_atomic_int_dec_and_test (&spec->ref_count)) { - GMountSpecItem *item = &g_array_index (spec->items, GMountSpecItem, i); - g_free (item->key); - g_free (item->value); + g_free (spec->mount_prefix); + for (i = 0; i < spec->items->len; i++) + { + GMountSpecItem *item = &g_array_index (spec->items, GMountSpecItem, i); + g_free (item->key); + g_free (item->value); + } + g_array_free (spec->items, TRUE); + + g_free (spec); } - g_array_free (spec->items, TRUE); - - g_free (spec); } GMountSpec * @@ -95,7 +105,7 @@ g_mount_spec_from_dbus (DBusMessageIter *iter) if (dbus_message_iter_get_arg_type (&spec_iter) != DBUS_TYPE_ARRAY || dbus_message_iter_get_element_type (&spec_iter) != DBUS_TYPE_STRUCT) { - g_mount_spec_free (spec); + g_mount_spec_unref (spec); return NULL; } |