20 #ifndef __PIPEWIRE_MAP_H__ 21 #define __PIPEWIRE_MAP_H__ 29 #include <spa/utils/defs.h> 49 #define PW_MAP_INIT(extend) (struct pw_map) { PW_ARRAY_INIT(extend), 0 } 51 #define pw_map_get_size(m) pw_array_get_len(&(m)->items, union pw_map_item) 52 #define pw_map_get_item(m,id) pw_array_get_unchecked(&(m)->items,id,union pw_map_item) 53 #define pw_map_item_is_free(item) ((item)->next & 0x1) 54 #define pw_map_id_is_free(m,id) (pw_map_item_is_free(pw_map_get_item(m,id))) 55 #define pw_map_check_id(m,id) ((id) < pw_map_get_size(m)) 56 #define pw_map_has_item(m,id) (pw_map_check_id(m,id) && !pw_map_id_is_free(m, id)) 57 #define pw_map_lookup_unchecked(m,id) pw_map_get_item(m,id)->data 60 #define PW_MAP_ID_TO_PTR(id) (SPA_UINT32_TO_PTR((id)<<1)) 62 #define PW_MAP_PTR_TO_ID(p) (SPA_PTR_TO_UINT32(p)>>1) 83 pw_array_clear(&map->
items);
104 return SPA_ID_INVALID;
static void pw_map_clear(struct pw_map *map)
Clear a map.
Definition: map.h:81
#define pw_map_get_size(m)
Definition: map.h:51
static bool pw_map_insert_at(struct pw_map *map, uint32_t id, void *data)
Insert data in the map at an index.
Definition: map.h:119
static void * pw_array_add(struct pw_array *arr, size_t size)
Add ref size bytes to arr.
Definition: array.h:98
uint32_t free_list
the free items
Definition: map.h:46
#define pw_map_get_item(m, id)
Definition: map.h:52
#define pw_array_for_each(pos, array)
Definition: array.h:56
static void pw_map_for_each(struct pw_map *map, void(*func)(void *, void *), void *data)
Iterate all map items.
Definition: map.h:168
void * data
pointer to array data
Definition: array.h:37
uint32_t next
next free index
Definition: map.h:39
#define pw_map_item_is_free(item)
Definition: map.h:53
static void pw_map_init(struct pw_map *map, size_t size, size_t extend)
Initialize a map.
Definition: map.h:70
#define pw_map_check_id(m, id)
Definition: map.h:55
static void pw_array_init(struct pw_array *arr, size_t extend)
Initialize the array with given extend.
Definition: array.h:62
static bool pw_array_ensure_size(struct pw_array *arr, size_t size)
Make sure size bytes can be added to the array.
Definition: array.h:76
static void * pw_map_lookup(struct pw_map *map, uint32_t id)
Find an item in the map.
Definition: map.h:152
An array object.
Definition: array.h:36
An entry in the map.
Definition: map.h:38
static void pw_map_remove(struct pw_map *map, uint32_t id)
Remove an item at index.
Definition: map.h:140
size_t extend
number of bytes to extend with
Definition: array.h:40
static uint32_t pw_map_insert_new(struct pw_map *map, void *data)
Insert data in the map.
Definition: map.h:92
void * data
data of this item, must be an even address
Definition: map.h:40
size_t size
length of array in bytes
Definition: array.h:38
struct pw_array items
an array with the map items
Definition: map.h:45
A map.
Definition: map.h:44