aboutsummaryrefslogtreecommitdiffstats
path: root/src/symap.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-08-10 21:24:37 -0400
committerDavid Robillard <d@drobilla.net>2022-08-17 13:51:23 -0400
commit7dfdb1744c99d874f7672250cd90b1b9d8d904f2 (patch)
tree5c4f93b77b99e674cdb528d2bac7f28798f37666 /src/symap.h
parent565366ae88efcb0e384039f17c0253917ddb5d63 (diff)
downloadjalv-7dfdb1744c99d874f7672250cd90b1b9d8d904f2.tar.gz
jalv-7dfdb1744c99d874f7672250cd90b1b9d8d904f2.tar.bz2
jalv-7dfdb1744c99d874f7672250cd90b1b9d8d904f2.zip
Clean up symap implementation and run unit test
Diffstat (limited to 'src/symap.h')
-rw-r--r--src/symap.h23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/symap.h b/src/symap.h
index ed74157..74dc59a 100644
--- a/src/symap.h
+++ b/src/symap.h
@@ -12,11 +12,14 @@
#ifndef SYMAP_H
#define SYMAP_H
+#include "zix/attributes.h"
+
#include <stdint.h>
typedef struct SymapImpl Symap;
/// Create a new symbol map
+ZIX_MALLOC_FUNC
Symap*
symap_new(void);
@@ -24,24 +27,18 @@ symap_new(void);
void
symap_free(Symap* map);
-/// Map a string to a symbol ID if it is already mapped, otherwise return 0
+/// Map a string to a symbol if it is already mapped, otherwise return 0
+ZIX_PURE_FUNC
uint32_t
-symap_try_map(Symap* map, const char* sym);
-
-/**
- Map a string to a symbol ID.
+symap_try_map(const Symap* map, const char* sym);
- Note that 0 is never a valid symbol ID.
-*/
+/// Map a string to a symbol
uint32_t
symap_map(Symap* map, const char* sym);
-/**
- Unmap a symbol ID back to a symbol, or NULL if no such ID exists.
-
- Note that 0 is never a valid symbol ID.
-*/
+/// Unmap a symbol back to a string if possible, otherwise return NULL
+ZIX_PURE_FUNC
const char*
-symap_unmap(Symap* map, uint32_t id);
+symap_unmap(const Symap* map, uint32_t id);
#endif // SYMAP_H