Some C containers
https://github.com/Bigfoot71/c-stash.git
Stash is a lightweight C library that provides basic data structures such as dynamic arrays, hash maps with uint32_t keys, and a registry with unique IDs. It allows for generic manipulation of these structures using void* pointers.
stash_arr: Generic dynamic array.stash_umap: Hash map with uint32_t keys.stash_reg: Element registry with unique IDs.Stash allows you to customize memory allocators by defining the following macros before including the header file:
#define STASH_MALLOC(sz) malloc(sz)
#define STASH_REALLOC(nb, sz) realloc(nb, sz)
#define STASH_FREE(mem) free(mem)
If these are not defined, the standard malloc(), realloc(), and free() functions will be used.
stash_arr arr = stash_arr_create(10, sizeof(int));
int value = 42;
stash_arr_push_back(&arr, &value);
stash_umap map = stash_umap_create(10, sizeof(int));
int value = 42;
stash_umap_insert(&map, 1234, &value);
stash_reg reg = stash_reg_create(10, sizeof(int));
int value = 42;
uint32_t id = stash_reg_push(®, &value);
The library exposes functions to manage each container (array, hashmap, registry) and perform operations like insertion, removal, iteration, and memory management.
stash_arr_create() : Creates a dynamic array.stash_umap_create() : Creates a hash map.stash_reg_create() : Creates an element registry.stash.h header file for the full list of functions.
To compile and use this library, simply include the stash.h header file in your C project and define STASH_IMPL at least once before including the header to enable the implementation.
This project is distributed under the MIT License. See the LICENSE file for more information.