25 #ifndef PIPEWIRE_MAP_H 26 #define PIPEWIRE_MAP_H 60 #define PW_MAP_INIT(extend) (struct pw_map) { PW_ARRAY_INIT(extend), SPA_ID_INVALID } 62 #define pw_map_get_size(m) pw_array_get_len(&(m)->items, union pw_map_item) 63 #define pw_map_get_item(m,id) pw_array_get_unchecked(&(m)->items,id,union pw_map_item) 64 #define pw_map_item_is_free(item) ((item)->next & 0x1) 65 #define pw_map_id_is_free(m,id) (pw_map_item_is_free(pw_map_get_item(m,id))) 66 #define pw_map_check_id(m,id) ((id) < pw_map_get_size(m)) 67 #define pw_map_has_item(m,id) (pw_map_check_id(m,id) && !pw_map_id_is_free(m, id)) 68 #define pw_map_lookup_unchecked(m,id) pw_map_get_item(m,id)->data 71 #define PW_MAP_ID_TO_PTR(id) (SPA_UINT32_TO_PTR((id)<<1)) 73 #define PW_MAP_PTR_TO_ID(p) (SPA_PTR_TO_UINT32(p)>>1) 80 static inline void pw_map_init(
struct pw_map *map,
size_t size,
size_t extend)
90 static inline void pw_map_clear(
struct pw_map *map)
92 pw_array_clear(&map->
items);
95 static inline void pw_map_reset(
struct pw_map *map)
97 pw_array_reset(&map->
items);
107 static inline uint32_t pw_map_insert_new(
struct pw_map *map,
void *
data)
134 static inline int pw_map_insert_at(
struct pw_map *map, uint32_t
id,
void *
data)
141 else if (
id == size) {
157 static inline void pw_map_remove(
struct pw_map *map, uint32_t
id)
168 static inline void *pw_map_lookup(
struct pw_map *map, uint32_t
id)
186 static inline int pw_map_for_each(
struct pw_map *map,
#define pw_map_get_item(m, id)
Definition: map.h:63
#define SPA_ID_INVALID
Definition: defs.h:181
#define SPA_LIKELY(x)
Definition: defs.h:231
#define pw_map_item_is_free(item)
Definition: map.h:64
uint32_t free_list
the free items
Definition: map.h:57
#define pw_array_for_each(pos, array)
Definition: array.h:72
#define pw_map_check_id(m, id)
Definition: map.h:66
void * data
pointer to array data
Definition: array.h:49
static uint32_t int int res
Definition: core.h:328
uint32_t next
next free index
Definition: map.h:50
static uint32_t id
Definition: core.h:328
#define pw_map_get_size(m)
Definition: map.h:62
An entry in the map.
Definition: map.h:49
size_t extend
number of bytes to extend with
Definition: array.h:52
void * data
data of this item, must be an even address
Definition: map.h:51
size_t size
length of array in bytes
Definition: array.h:50
struct pw_array items
an array with the map items
Definition: map.h:56
A map.
Definition: map.h:55
enum spa_log_level level const char int const char * func
Definition: log-impl.h:43