aboutsummaryrefslogtreecommitdiff
path: root/map.h
diff options
context:
space:
mode:
authorRandy Palamar <randy@rnpnr.xyz>2025-12-05 12:05:32 -0700
committerRandy Palamar <randy@rnpnr.xyz>2025-12-16 11:28:44 -0700
commit1d1d19ed30309b39fc5e43c830cabb4cdd004d07 (patch)
tree56bb7c09d3b07118e39e7fc6174403b0235d56a7 /map.h
parent65dd46e0bba74948c824370a06e509cba462cd72 (diff)
downloadvis-1d1d19ed30309b39fc5e43c830cabb4cdd004d07.tar.gz
vis-1d1d19ed30309b39fc5e43c830cabb4cdd004d07.tar.xz
mark all functions in headers with VIS_EXPORT or VIS_INTERNAL
if vis actually wants to be a library exported symbols may need mark up depending on the platform (eg. __declspec(dllexport)). This needs to be hidden behind a macro because the way you export is not the same on every platform. I did this based on the assumption that vis.h was supposed to be the only interface to the "vis" library. Since nobody actually uses vis as a library I have no idea if this is actually correct. Anyway marking up all prototypes like this allows for one to convert all functions to static if a single translation unit is used by inserting at the start: #define VIS_INTERNAL static #define VIS_EXPORT static
Diffstat (limited to 'map.h')
-rw-r--r--map.h30
1 files changed, 15 insertions, 15 deletions
diff --git a/map.h b/map.h
index d3457d9..490b4d9 100644
--- a/map.h
+++ b/map.h
@@ -1,7 +1,7 @@
#ifndef MAP_H
#define MAP_H
-#include <stdbool.h>
+#include "util.h"
/**
* @file
@@ -13,19 +13,19 @@
typedef struct Map Map;
/** Allocate a new map. */
-Map *map_new(void);
+VIS_INTERNAL Map *map_new(void);
/**
* Lookup a value, returns ``NULL`` if not found.
* @param map The map to search within.
* @param key The key to look up.
*/
-void *map_get(const Map *map, const char *key);
+VIS_INTERNAL void *map_get(const Map *map, const char *key);
/**
* Get first element of the map, or ``NULL`` if empty.
* @param map The map to query.
* @param key Updated with the key of the first element.
*/
-void *map_first(const Map *map, const char **key);
+VIS_INTERNAL void *map_first(const Map *map, const char **key);
/**
* Lookup element by unique prefix match.
* @param map The map to search within.
@@ -33,14 +33,14 @@ void *map_first(const Map *map, const char **key);
* @return The corresponding value, if the given prefix is unique.
* Otherwise ``NULL``.
*/
-void *map_closest(const Map *map, const char *prefix);
+VIS_INTERNAL void *map_closest(const Map *map, const char *prefix);
/**
* Check whether the map contains the given prefix, or
* whether it can be extended to match a key of a map element.
* @param map The map to check.
* @param prefix The prefix to search for.
*/
-bool map_contains(const Map *map, const char *prefix);
+VIS_INTERNAL bool map_contains(const Map *map, const char *prefix);
/**
* Store a key value pair in the map.
* @param map The map to store the key-value pair in.
@@ -49,20 +49,20 @@ bool map_contains(const Map *map, const char *prefix);
* @return False if we run out of memory, or if the key
* already appears in the map.
*/
-bool map_put(Map *map, const char *key, const void *value);
+VIS_INTERNAL bool map_put(Map *map, const char *key, const void *value);
/**
* Remove a map element.
* @param map The map to remove the element from.
* @param key The key of the element to remove.
* @return The removed entry or ``NULL`` if no such element exists.
*/
-void *map_delete(Map *map, const char *key);
+VIS_INTERNAL void *map_delete(Map *map, const char *key);
/**
* Copy all entries from ``src`` into ``dest``, overwrites existing entries in ``dest``.
* @param dest The destination map.
* @param src The source map.
*/
-bool map_copy(Map *dest, Map *src);
+VIS_INTERNAL bool map_copy(Map *dest, Map *src);
/**
* Ordered iteration over a map.
* Invokes the passed callback for every map entry.
@@ -71,7 +71,7 @@ bool map_copy(Map *dest, Map *src);
* @param handle A function invoked for every map element.
* @param data A context pointer, passed as last argument to ``handle``.
*/
-void map_iterate(const Map *map, bool (*handle)(const char *key, void *value, void *data), const void *data);
+VIS_INTERNAL void map_iterate(const Map *map, bool (*handle)(const char *key, void *value, void *data), const void *data);
/**
* Get a sub map matching a prefix.
* @param map The map to get the sub-map from.
@@ -81,22 +81,22 @@ void map_iterate(const Map *map, bool (*handle)(const char *key, void *value, vo
* Do not alter the map while using the return value.
* @endrst
*/
-const Map *map_prefix(const Map *map, const char *prefix);
+VIS_INTERNAL const Map *map_prefix(const Map *map, const char *prefix);
/**
* Test whether the map is empty (contains no elements).
* @param map The map to check.
*/
-bool map_empty(const Map *map);
+VIS_INTERNAL bool map_empty(const Map *map);
/**
* Empty the map.
* @param map The map to clear.
*/
-void map_clear(Map *map);
+VIS_INTERNAL void map_clear(Map *map);
/**
* Release all memory associated with this map.
* @param map The map to free.
*/
-void map_free(Map *map);
+VIS_INTERNAL void map_free(Map *map);
/**
* Call `free(3)` for every map element, then free the map itself.
* @param map The map to free its elements and itself.
@@ -104,6 +104,6 @@ void map_free(Map *map);
* .. warning:: Assumes map elements to be pointers.
* @endrst
*/
-void map_free_full(Map *map);
+VIS_INTERNAL void map_free_full(Map *map);
#endif