PipeWire 0.1.9

Public Member Functions | Data Fields
pw_map Class Reference

A map. More...

Collaboration diagram for pw_map:
[legend]

## Public Member Functions
#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. More...
#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. More...
static void | pw_map_init (struct pw_map *map, size_t size, size_t extend)
| Initialize a map. More...
static void | pw_map_clear (struct pw_map *map)
| Clear a map. More...
static uint32_t | pw_map_insert_new (struct pw_map *map, void *data)
| Insert data in the map. More...
static bool | pw_map_insert_at (struct pw_map *map, uint32_t id, void *data)
| Insert data in the map at an index. More...
static void | pw_map_remove (struct pw_map *map, uint32_t id)
| Remove an item at index. More...
static void * | pw_map_lookup (struct pw_map *map, uint32_t id)
| Find an item in the map. More...
static void | pw_map_for_each (struct pw_map *map, void(*func)(void *, void *), void *data)
| Iterate all map items. More...

## Data Fields
struct pw_array | items
| an array with the map items More...
uint32_t | free_list
| the free items More...

## Detailed Description

A map.

A map that holds objects indexed by id.

## Member Function Documentation

## ◆ pw_map_clear()

static void pw_map_clear | ( | struct pw_map * | map | ) |
| inline

Clear a map.

Parameters

  map | the map to clear

Referenced by pw_core::pw_core_destroy(), and pw_remote_disconnect().

## ◆ pw_map_for_each()

static void pw_map_for_each | ( | struct pw_map * | map,
|  | void(*)(void *, void *) | func,
|  | void * | data
| ) |  |
| inline

Iterate all map items.

Parameters

  map | the map to iterate
  func | the function to call for each item
  data | data to pass to func

References pw_map_item::data, items, pw_array_for_each, and pw_map_item_is_free.

Referenced by pw_client::pw_client_destroy().

## ◆ pw_map_init()

static void pw_map_init | ( | struct pw_map * | map,
|  | size_t | size,
|  | size_t | extend
| ) |  |
| inline

Initialize a map.

Parameters

  map | the map to initialize
  size | the initial size of the map
  extend | the amount to bytes to grow the map with when needed

References pw_array::extend, free_list, items, pw_array::pw_array_ensure_size(), pw_array::pw_array_init(), and pw_array::size.

Referenced by pw_core::pw_core_new(), and pw_remote_new().

## ◆ pw_map_insert_at()

static bool pw_map_insert_at | ( | struct pw_map * | map,
|  | uint32_t | id,
|  | void * | data
| ) |  |
| inline

Insert data in the map at an index.

Parameters

  map | the map to inser into
  id | the index to insert at
  data | the data to insert

Returns
  true on success, false when the index is invalid

References pw_map_item::data, items, pw_array::pw_array_add(), pw_map_get_item, and pw_map_get_size.

Referenced by pw_port_add(), pw_resource_destroy(), and pw_resource_new().

## ◆ pw_map_insert_new()

static uint32_t pw_map_insert_new | ( | struct pw_map * | map,
|  | void * | data
| ) |  |
| inline

Insert data in the map.

Parameters

  map | the map to insert into
  data | the item to add

Returns
  the id where the item was inserted

References pw_array::data, pw_map_item::data, free_list, items, pw_map_item::next, and pw_array::pw_array_add().

Referenced by pw_global::pw_global_register(), pw_node::pw_node_get_free_port(), pw_node_get_free_port_id(), pw_proxy::pw_proxy_new(), and pw_resource_new().

## ◆ pw_map_lookup()

static void * pw_map_lookup | ( | struct pw_map * | map,
|  | uint32_t | id
| ) |  |
| inline

Find an item in the map.

Parameters

  map | the map to use
  id | the index to look at

Returns
  the item at id or NULL when no such item exists

References pw_map_item::data, pw_map_check_id, pw_map_get_item, and pw_map_item_is_free.

Referenced by pw_client_find_resource(), pw_core_find_global(), pw_node_find_port(), and pw_remote_find_proxy().

## ◆ pw_map_remove()

static void pw_map_remove | ( | struct pw_map * | map,
|  | uint32_t | id
| ) |  |
| inline

Remove an item at index.

Parameters

  map | the map to remove from
  id | the index to remove

References free_list, and pw_map_get_item.

Referenced by pw_global::pw_global_destroy(), and pw_proxy::pw_proxy_destroy().

## Field Documentation

## ◆ free_list

uint32_t pw_map::free_list

the free items

Referenced by pw_map_init(), pw_map_insert_new(), and pw_map_remove().

## ◆ items

struct pw_array pw_map::items

an array with the map items

Referenced by pw_map_for_each(), pw_map_init(), pw_map_insert_at(), and pw_map_insert_new().

The documentation for this class was generated from the following file:

- map.h