Mercurial
diff dowa/dowa.h @ 60:d64a8c189a77
Merged
| author | June Park <me@mrjunejune.com> |
|---|---|
| date | Sat, 20 Dec 2025 13:56:01 -0500 |
| parents | e06bc03d9618 |
| children | fff1b048dda6 |
line wrap: on
line diff
--- a/dowa/dowa.h Tue Dec 16 21:01:45 2025 -0500 +++ b/dowa/dowa.h Sat Dec 20 13:56:01 2025 -0500 @@ -6,6 +6,7 @@ #include <stdlib.h> // only for malloc, free, stuff #include <assert.h> // mostly for TODO #include <dirent.h> // some functions loop through files +#include <math.h> // I am not re-writing stuff I guess... #include <sys/stat.h> #include <limits.h> @@ -54,6 +55,12 @@ extern void Dowa_Arena_Destroy(Dowa_PArena arena); /* Strdup but saves within the arena */ extern void *Dowa_Arena_Copy(Dowa_PArena p_arena, const void *src, size_t size); +/* Resets the arena offset to 0, allowing reuse without freeing */ +extern void Dowa_Arena_Reset(Dowa_PArena p_arena); +/* Returns the current number of bytes allocated in the arena */ +extern size_t Dowa_Arena_Get_Used(Dowa_PArena p_arena); +/* Returns the remaining capacity in bytes */ +extern size_t Dowa_Arena_Get_Remaining(Dowa_PArena p_arena); // --- HashMap --- // @@ -64,7 +71,7 @@ DOWA_HASH_MAP_TYPE_INT // Integer value } Dowa_HashMap_ValueType; -typedef struct { +typedef struct Dowa_HashEntry { char *key; void *buffer; size_t capacity; @@ -97,6 +104,12 @@ extern int32 Dowa_HashMap_Push_Value_With_Type_NoCopy(Dowa_PHashMap p_hash_map, const char *key, void *value, size_t value_size, Dowa_HashMap_ValueType type); /* Removes the entry with the specified key from the hashmap and frees its data if owned. */ extern void Dowa_HashMap_Pop_Key(Dowa_PHashMap p_hash_map, const char *key); +/* Returns TRUE if the key exists in the hashmap, FALSE otherwise. */ +extern boolean Dowa_HashMap_Has_Key(Dowa_PHashMap p_hash_map, const char *key); +/* Removes all entries from the hashmap without destroying it. */ +extern void Dowa_HashMap_Clear(Dowa_PHashMap p_hash_map); +/* Returns the number of entries currently in the hashmap. */ +extern uint32 Dowa_HashMap_Get_Count(Dowa_PHashMap p_hash_map); // --- Utility Functions --- // /* Prints all entries in the hashmap to stdout for debugging purposes. */