mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
map: use invalid value for empty list
This commit is contained in:
parent
d4ab36d52a
commit
ce4232cbc7
1 changed files with 3 additions and 3 deletions
|
|
@ -71,7 +71,7 @@ static inline void pw_map_init(struct pw_map *map, size_t size, size_t extend)
|
||||||
{
|
{
|
||||||
pw_array_init(&map->items, extend);
|
pw_array_init(&map->items, extend);
|
||||||
pw_array_ensure_size(&map->items, size * sizeof(union pw_map_item));
|
pw_array_ensure_size(&map->items, size * sizeof(union pw_map_item));
|
||||||
map->free_list = 0;
|
map->free_list = SPA_ID_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Clear a map
|
/** Clear a map
|
||||||
|
|
@ -94,7 +94,7 @@ static inline uint32_t pw_map_insert_new(struct pw_map *map, void *data)
|
||||||
union pw_map_item *start, *item;
|
union pw_map_item *start, *item;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
|
||||||
if (map->free_list) {
|
if (map->free_list != SPA_ID_INVALID) {
|
||||||
start = (union pw_map_item *) map->items.data;
|
start = (union pw_map_item *) map->items.data;
|
||||||
item = &start[map->free_list >> 1];
|
item = &start[map->free_list >> 1];
|
||||||
map->free_list = item->next;
|
map->free_list = item->next;
|
||||||
|
|
@ -139,7 +139,7 @@ static inline bool pw_map_insert_at(struct pw_map *map, uint32_t id, void *data)
|
||||||
*/
|
*/
|
||||||
static inline void pw_map_remove(struct pw_map *map, uint32_t id)
|
static inline void pw_map_remove(struct pw_map *map, uint32_t id)
|
||||||
{
|
{
|
||||||
pw_map_get_item(map, id)->next = map->free_list | 1;
|
pw_map_get_item(map, id)->next = map->free_list;
|
||||||
map->free_list = (id << 1) | 1;
|
map->free_list = (id << 1) | 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue