id-map: add get_size method

This commit is contained in:
Wim Taymans 2017-03-14 20:17:51 +01:00
parent ff659ad1a7
commit 997aa036ba
2 changed files with 11 additions and 0 deletions

View file

@ -62,11 +62,19 @@ id_map_get_uri (SpaIDMap *map, uint32_t id)
return NULL;
}
static uint32_t
id_map_get_size (SpaIDMap *map)
{
IDMap *this = SPA_CONTAINER_OF (map, IDMap, map);
return pinos_map_get_size (&this->uris);
}
static IDMap default_id_map = {
{ sizeof (SpaIDMap),
NULL,
id_map_get_id,
id_map_get_uri,
id_map_get_size,
},
{ { NULL, } },
};

View file

@ -52,10 +52,13 @@ struct _SpaIDMap {
const char * (*get_uri) (SpaIDMap *map,
uint32_t id);
uint32_t (*get_size) (SpaIDMap *map);
};
#define spa_id_map_get_id(n,...) (n)->get_id((n),__VA_ARGS__)
#define spa_id_map_get_uri(n,...) (n)->get_uri((n),__VA_ARGS__)
#define spa_id_map_get_size(n) (n)->get_size(n)
#ifdef __cplusplus
} /* extern "C" */