PipeWire 1.0.3
No Matches
map.h File Reference

pipewire/map.h More...

Go to the source code of this file.

Data Structures

struct  pw_map
 A map. More...


#define PW_MAP_INIT(extend)   ((struct pw_map) { PW_ARRAY_INIT(extend), SPA_ID_INVALID })
#define pw_map_get_size(m)   pw_array_get_len(&(m)->items, union pw_map_item)
 Get the number of currently allocated elements in the map.
#define pw_map_get_item(m, id)   pw_array_get_unchecked(&(m)->items,id,union pw_map_item)
#define pw_map_item_is_free(item)   ((item)->next & 0x1)
#define pw_map_id_is_free(m, id)   (pw_map_item_is_free(pw_map_get_item(m,id)))
#define pw_map_check_id(m, id)   ((id) < pw_map_get_size(m))
#define pw_map_has_item(m, id)   (pw_map_check_id(m,id) && !pw_map_id_is_free(m, id))
#define pw_map_lookup_unchecked(m, id)   pw_map_get_item(m,id)->data
#define PW_MAP_ID_TO_PTR(id)   (SPA_UINT32_TO_PTR((id)<<1))
 Convert an id to a pointer that can be inserted into the map.
#define PW_MAP_PTR_TO_ID(p)   (SPA_PTR_TO_UINT32(p)>>1)
 Convert a pointer to an id that can be retrieved from the map.


static void pw_map_init (struct pw_map *map, size_t size, size_t extend)
 Initialize a map.
static void pw_map_clear (struct pw_map *map)
 Clear a map and free the data storage.
static void pw_map_reset (struct pw_map *map)
 Reset a map but keep previously allocated storage.
static uint32_t pw_map_insert_new (struct pw_map *map, void *data)
 Insert data in the map.
static int pw_map_insert_at (struct pw_map *map, uint32_t id, void *data)
 Replace the data in the map at an index.
static void pw_map_remove (struct pw_map *map, uint32_t id)
 Remove an item at index.
static void * pw_map_lookup (const struct pw_map *map, uint32_t id)
 Find an item in the map.
static int pw_map_for_each (const struct pw_map *map, int(*func)(void *item_data, void *data), void *data)
 Iterate all map items.

Detailed Description