D-Bus 1.15.8
Functions

Storing data by ID. More...

Functions

dbus_bool_t _dbus_data_slot_allocator_init (DBusDataSlotAllocator *allocator, DBusGlobalLock lock)
 Initializes a data slot allocator object, used to assign integer IDs for data slots. More...
 
dbus_bool_t _dbus_data_slot_allocator_alloc (DBusDataSlotAllocator *allocator, dbus_int32_t *slot_id_p)
 Allocates an integer ID to be used for storing data in a DBusDataSlotList. More...
 
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(). More...
 
void _dbus_data_slot_list_init (DBusDataSlotList *list)
 Initializes a slot list. More...
 
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. More...
 
void * _dbus_data_slot_list_get (DBusDataSlotAllocator *allocator, DBusDataSlotList *list, int slot)
 Retrieves data previously set with _dbus_data_slot_list_set_data(). More...
 
void _dbus_data_slot_list_clear (DBusDataSlotList *list)
 Frees all data slots contained in the list, calling application-provided free functions if they exist. More...
 
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. More...
 

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_data_slot_allocator_alloc()

dbus_bool_t _dbus_data_slot_allocator_alloc ( DBusDataSlotAllocator allocator,
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
allocatorthe allocator
slot_id_paddress to fill with the slot ID
Returns
TRUE on success

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

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

◆ _dbus_data_slot_allocator_free()

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 DBusDataSlotList 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
allocatorthe allocator
slot_id_paddress where we store the slot

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

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

◆ _dbus_data_slot_allocator_init()

dbus_bool_t _dbus_data_slot_allocator_init ( DBusDataSlotAllocator allocator,
DBusGlobalLock  lock 
)

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

Parameters
allocatorthe allocator to initialize

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

References DBusDataSlotAllocator::allocated_slots, DBusDataSlotAllocator::lock, DBusDataSlotAllocator::n_allocated_slots, DBusDataSlotAllocator::n_used_slots, NULL, and TRUE.

◆ _dbus_data_slot_list_clear()

void _dbus_data_slot_list_clear ( DBusDataSlotList list)

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

Parameters
listthe list to clear

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

References data, free_data_func, NULL, and DBusDataSlotList::slots.

Referenced by _dbus_data_slot_list_free().

◆ _dbus_data_slot_list_free()

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
listthe list to free

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

References _dbus_data_slot_list_clear(), dbus_free(), DBusDataSlotList::n_slots, NULL, and DBusDataSlotList::slots.

Referenced by _dbus_server_finalize_base().

◆ _dbus_data_slot_list_get()

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
allocatorthe allocator slot was allocated from
listthe data slot list
slotthe slot to get data from
Returns
the data, or NULL if not found

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

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

◆ _dbus_data_slot_list_init()

void _dbus_data_slot_list_init ( DBusDataSlotList list)

Initializes a slot list.

Parameters
listthe list to initialize.

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

References DBusDataSlotList::n_slots, NULL, and DBusDataSlotList::slots.

◆ _dbus_data_slot_list_set()

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
allocatorthe allocator to use
listthe data slot list
slotthe slot number
datathe data to store
free_data_funcfinalizer function for the data
old_free_funcfree function for any previously-existing data
old_datapreviously-existing data, should be freed with old_free_func
Returns
TRUE if there was enough memory to store the data

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

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