From 6843ad31769c088ca259020fd9ea8dfb3a51f68e Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sun, 22 Jun 2003 19:39:47 +0000 Subject: 2003-06-22 Havoc Pennington * dbus/dbus-dataslot.c (_dbus_data_slot_allocator_unref) (_dbus_data_slot_allocator_alloc): rework these to keep a reference count on each slot and automatically manage a global slot ID variable passed in by address * bus/bus.c: convert to new dataslot API * dbus/dbus-bus.c: convert to new dataslot API * dbus/dbus-connection.c: convert to new dataslot API * dbus/dbus-server.c: convert to new dataslot API * glib/dbus-gmain.c: ditto * bus/test.c: ditto * bus/connection.c: ditto --- dbus/dbus-dataslot.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'dbus/dbus-dataslot.h') diff --git a/dbus/dbus-dataslot.h b/dbus/dbus-dataslot.h index d4357325..6f591eb5 100644 --- a/dbus/dbus-dataslot.h +++ b/dbus/dbus-dataslot.h @@ -39,9 +39,16 @@ struct DBusDataSlot DBusFreeFunction free_data_func; /**< Free the application data */ }; +typedef struct DBusAllocatedSlot DBusAllocatedSlot; +struct DBusAllocatedSlot +{ + dbus_int32_t slot_id; /**< ID of this slot */ + int refcount; /**< Number of uses of the slot */ +}; + struct DBusDataSlotAllocator { - int *allocated_slots; /**< Allocated slots */ + DBusAllocatedSlot *allocated_slots; /**< Allocated slots */ int n_allocated_slots; /**< number of slots malloc'd */ int n_used_slots; /**< number of slots used */ DBusMutex *lock; /**< thread lock */ @@ -54,10 +61,11 @@ struct DBusDataSlotList }; dbus_bool_t _dbus_data_slot_allocator_init (DBusDataSlotAllocator *allocator); -int _dbus_data_slot_allocator_alloc (DBusDataSlotAllocator *allocator, - DBusMutex *mutex); +dbus_bool_t _dbus_data_slot_allocator_alloc (DBusDataSlotAllocator *allocator, + DBusMutex *mutex, + int *slot_id_p); void _dbus_data_slot_allocator_free (DBusDataSlotAllocator *allocator, - int slot_id); + int *slot_id_p); void _dbus_data_slot_list_init (DBusDataSlotList *list); dbus_bool_t _dbus_data_slot_list_set (DBusDataSlotAllocator *allocator, DBusDataSlotList *list, -- cgit