Header for namemap.c.
More...
#include "lib/cc/compat_compiler.h"
#include "ext/ht.h"
#include <stddef.h>
Go to the source code of this file.
Header for namemap.c.
Definition in file namemap.h.
◆ NAMEMAP_ERR
#define NAMEMAP_ERR UINT_MAX |
Returned in place of an identifier when an error occurs.
Definition at line 23 of file namemap.h.
◆ namemap_clear()
Release all storage held in map.
Definition at line 177 of file namemap.c.
◆ namemap_fmt_name()
const char* namemap_fmt_name |
( |
const namemap_t * |
map, |
|
|
unsigned |
id |
|
) |
| |
Return the name that map associates with a given id, or a pointer to a statically allocated string describing the value of id if no such name exists.
Definition at line 70 of file namemap.c.
◆ namemap_get_id()
unsigned namemap_get_id |
( |
const namemap_t * |
map, |
|
|
const char * |
name |
|
) |
| |
Return the identifier currently associated by map with the name name, or NAMEMAP_ERR if no such identifier exists.
Definition at line 114 of file namemap.c.
◆ namemap_get_name()
const char* namemap_get_name |
( |
const namemap_t * |
map, |
|
|
unsigned |
id |
|
) |
| |
Return the name that map associates with a given id, or NULL if there is no such name.
Definition at line 54 of file namemap.c.
Referenced by namemap_fmt_name().
◆ namemap_get_or_create_id()
unsigned namemap_get_or_create_id |
( |
namemap_t * |
map, |
|
|
const char * |
name |
|
) |
| |
Return the identifier associated by map with the name name, allocating a new identifier in map if none exists.
Return NAMEMAP_ERR if name is too long, or if there are no more identifiers we can allocate.
Definition at line 133 of file namemap.c.
◆ namemap_get_size()
size_t namemap_get_size |
( |
const namemap_t * |
map | ) |
|
Return the number of entries in 'names'
Definition at line 165 of file namemap.c.
◆ namemap_init()
Set up an uninitialized map.
Definition at line 44 of file namemap.c.