Main Page   Modules   Data Structures   File List   Data Fields   Related Pages  

Data slots
[D-BUS internal implementation details]

Storing data by ID. More...

Functions

dbus_bool_t _dbus_data_slot_allocator_init (DBusDataSlotAllocator *allocator)
 Initializes a data slot allocator object, used to assign integer IDs for data slots.

dbus_bool_t _dbus_data_slot_allocator_alloc (DBusDataSlotAllocator *allocator, DBusMutex *mutex, dbus_int32_t *slot_id_p)
 Allocates an integer ID to be used for storing data in a #DBusDataSlotList.

void _dbus_data_slot_allocator_free (DBusDataSlotAllocator *allocator, dbus_int32_t *slot_id_p)
 Deallocates an ID previously allocated with _dbus_data_slot_allocator_alloc().

void _dbus_data_slot_list_init (DBusDataSlotList *list)
 Initializes a slot list.

dbus_bool_t _dbus_data_slot_list_set (DBusDataSlotAllocator *allocator, DBusDataSlotList *list, int slot, void *data, DBusFreeFunction free_data_func, DBusFreeFunction *old_free_func, void **old_data)
 Stores a pointer in the data slot list, along with an optional function to be used for freeing the data when the data is set again, or when the slot list is finalized.

void * _dbus_data_slot_list_get (DBusDataSlotAllocator *allocator, DBusDataSlotList *list, int slot)
 Retrieves data previously set with _dbus_data_slot_list_set_data().

void _dbus_data_slot_list_free (DBusDataSlotList *list)
 Frees the data slot list and all data slots contained in it, calling application-provided free functions if they exist.


Detailed Description

Storing data by ID.

Types and functions related to storing data by an allocated ID. This is used for dbus_connection_set_data(), dbus_server_set_data(), etc.


Function Documentation

dbus_bool_t _dbus_data_slot_allocator_alloc DBusDataSlotAllocator *    allocator,
DBusMutex *    mutex,
dbus_int32_t   slot_id_p
 

Allocates an integer ID to be used for storing data in a #DBusDataSlotList.

If the value at *slot_id_p is not -1, this function just increments the refcount for the existing slot ID. If the value is -1, a new slot ID is allocated and stored at *slot_id_p.

Parameters:
allocator the allocator
mutex the lock for this allocator
slot_id_p address to fill with the slot ID
Returns:
TRUE on success

Definition at line 67 of file dbus-dataslot.c.

References _dbus_assert, _dbus_data_slot_allocator_alloc(), dbus_int32_t, dbus_mutex_lock(), dbus_mutex_unlock(), dbus_realloc(), FALSE, and NULL.

Referenced by _dbus_data_slot_allocator_alloc(), dbus_connection_allocate_data_slot(), dbus_message_allocate_data_slot(), and dbus_server_allocate_data_slot().

void _dbus_data_slot_allocator_free DBusDataSlotAllocator *    allocator,
dbus_int32_t   slot_id_p
 

Deallocates an ID previously allocated with _dbus_data_slot_allocator_alloc().

Existing data stored on existing #DBusDataList objects with this ID will be freed when the data list is finalized, but may not be retrieved (and may only be replaced if someone else reallocates the slot). The slot value is reset to -1 if this is the last unref.

Parameters:
allocator the allocator
slot_id_p address where we store the slot

Definition at line 161 of file dbus-dataslot.c.

References _dbus_assert, _dbus_data_slot_allocator_free(), dbus_free(), dbus_mutex_lock(), dbus_mutex_unlock(), and NULL.

Referenced by _dbus_data_slot_allocator_free(), dbus_connection_free_data_slot(), dbus_message_free_data_slot(), and dbus_server_free_data_slot().

dbus_bool_t _dbus_data_slot_allocator_init DBusDataSlotAllocator *    allocator
 

Initializes a data slot allocator object, used to assign integer IDs for data slots.

Parameters:
allocator the allocator to initialize

Definition at line 44 of file dbus-dataslot.c.

References NULL, and TRUE.

void _dbus_data_slot_list_free DBusDataSlotList *    list
 

Frees the data slot list and all data slots contained in it, calling application-provided free functions if they exist.

Parameters:
list the list to free

Definition at line 326 of file dbus-dataslot.c.

References dbus_free(), and NULL.

Referenced by _dbus_server_finalize_base(), and dbus_message_unref().

void* _dbus_data_slot_list_get DBusDataSlotAllocator *    allocator,
DBusDataSlotList *    list,
int    slot
 

Retrieves data previously set with _dbus_data_slot_list_set_data().

The slot must still be allocated (must not have been freed).

Parameters:
allocator the allocator slot was allocated from
list the data slot list
slot the slot to get data from
Returns:
the data, or NULL if not found

Definition at line 295 of file dbus-dataslot.c.

References _dbus_assert, dbus_mutex_lock(), dbus_mutex_unlock(), FALSE, and NULL.

Referenced by dbus_connection_get_data(), dbus_message_get_data(), and dbus_server_get_data().

void _dbus_data_slot_list_init DBusDataSlotList *    list
 

Initializes a slot list.

Parameters:
list the list to initialize.

Definition at line 209 of file dbus-dataslot.c.

References NULL.

Referenced by _dbus_connection_new_for_transport(), and _dbus_server_init_base().

dbus_bool_t _dbus_data_slot_list_set DBusDataSlotAllocator *    allocator,
DBusDataSlotList *    list,
int    slot,
void *    data,
DBusFreeFunction    free_data_func,
DBusFreeFunction   old_free_func,
void **    old_data
 

Stores a pointer in the data slot list, along with an optional function to be used for freeing the data when the data is set again, or when the slot list is finalized.

The slot number must have been allocated with _dbus_data_slot_allocator_alloc() for the same allocator passed in here. The same allocator has to be used with the slot list every time.

Parameters:
allocator the allocator to use
list the data slot list
slot the slot number
data the data to store
free_data_func finalizer function for the data
old_free_func free function for any previously-existing data
old_data previously-existing data, should be freed with old_free_func
Returns:
TRUE if there was enough memory to store the data

Definition at line 233 of file dbus-dataslot.c.

References _dbus_assert, dbus_mutex_lock(), dbus_mutex_unlock(), dbus_realloc(), FALSE, NULL, and TRUE.

Referenced by dbus_connection_set_data(), dbus_message_set_data(), and dbus_server_set_data().


Generated on Wed Oct 22 14:05:07 2003 for D-BUS by doxygen1.3-rc3