Mercurial
diff dowa/dowa.h @ 72:4532ce6d9eb8
[Seobeo] Added router to the server logic. Few dowa string manipulation logics.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Mon, 29 Dec 2025 07:50:07 -0800 |
| parents | 75de5903355c |
| children | 4b96794c8d59 |
line wrap: on
line diff
--- a/dowa/dowa.h Sun Dec 28 20:34:22 2025 -0800 +++ b/dowa/dowa.h Mon Dec 29 07:50:07 2025 -0800 @@ -66,7 +66,7 @@ DLAPI Dowa_Arena *Dowa_Arena_Create(size_t capacity); DLAPI void *Dowa_Arena_Allocate(Dowa_Arena *p_arena, size_t size); DLAPI void *Dowa_Arena_Allocate_Aligned(Dowa_Arena *p_arena, size_t size, size_t alignment); -DLAPI void Dowa_Arena_Destroy(Dowa_Arena *p_arena); +DLAPI void Dowa_Arena_Free(Dowa_Arena *p_arena); DLAPI void *Dowa_Arena_Copy(Dowa_Arena *p_arena, const void *p_src, size_t size); DLAPI void Dowa_Arena_Reset(Dowa_Arena *p_arena); DLAPI size_t Dowa_Arena_Get_Used(Dowa_Arena *p_arena); @@ -211,76 +211,15 @@ DLAPI void dowa__hashmap_free(void* p_map); DLAPI size_t dowa__hashmap_count(void* p_map); -// --- OLD API (kept for reference, will be removed after migration) --- // -/* - - -OLD HashMap API - Commented out for migration -typedef enum { - DOWA_HASH_MAP_TYPE_BUFFER, - DOWA_HASH_MAP_TYPE_STRING, - DOWA_HASH_MAP_TYPE_HASHMAP, - DOWA_HASH_MAP_TYPE_INT -} Dowa_HashMap_ValueType; - -typedef struct Dowa_HashEntry { - char *key; - void *buffer; - size_t capacity; - Dowa_HashMap_ValueType type; - struct Dowa_HashEntry *next; -} Dowa_HashEntry; - -typedef struct { - Dowa_HashEntry **entries; - size_t capacity; - uint32 current_capacity; - Dowa_Arena *p_arena; -} Dowa_HashMap; - -extern Dowa_HashMap *Dowa_HashMap_Create(size_t capacity); -extern Dowa_HashMap *Dowa_HashMap_Create_With_Arena(size_t capacity, Dowa_Arena *arena); -extern void Dowa_HashMap_Destroy(Dowa_HashMap *p_hash_map); -extern int32 Dowa_HashMap_Get_Position(Dowa_HashMap *p_hash_map, const char *key); -extern void *Dowa_HashMap_Get(Dowa_HashMap *p_hash_map, const char *key); -extern void Dowa_HashMap_Push_Value(Dowa_HashMap *p_hash_map, const char *key, void *value, size_t value_size); -extern int32 Dowa_HashMap_Push_Value_With_Type(Dowa_HashMap *p_hash_map, const char *key, void *value, size_t value_size, Dowa_HashMap_ValueType type); -extern int32 Dowa_HashMap_Push_Value_With_Type_NoCopy(Dowa_HashMap *p_hash_map, const char *key, void *value, size_t value_size, Dowa_HashMap_ValueType type); -extern void Dowa_HashMap_Pop_Key(Dowa_HashMap *p_hash_map, const char *key); -extern boolean Dowa_HashMap_Has_Key(Dowa_HashMap *p_hash_map, const char *key); -extern void Dowa_HashMap_Clear(Dowa_HashMap *p_hash_map); -extern uint32 Dowa_HashMap_Get_Count(Dowa_HashMap *p_hash_map); - -OLD Array API - Commented out for migration -#define DOWA_ARRAY_DEFAULT_CAPACITY 256 - -typedef struct { - void *value; - uint32 length; -} Dowa_Array_Item; - -typedef struct { - uint32 capacity; - uint32 current_length; - Dowa_Array_Item *items; -} Dowa_Array; - -#define Dowa_Array_Push_Value(dowa_array, buffer, length) ... -Dowa_Array *Dowa_Array_Init(); - -OLD Utility Functions - Will be migrated -extern void Dowa_HashMap_Print(Dowa_HashMap *map); -extern int Dowa_HashMap_Cache_Folder(Dowa_HashMap *map, const char *folder_path); -*/ - // --- String Manipulation --- // -DLAPI const char *Dowa_String_Slice(const char *p_from, size_t start, size_t end); +DLAPI char *Dowa_String_Slice(char *from, size_t start, size_t end, Dowa_Arena *p_arena); +DLAPI char **Dowa_String_Split(char *from, char *token, int32 from_length, int32 token_length, Dowa_Arena *p_arena); +DLAPI char *Dowa_String_Copy_Arena(char *from, Dowa_Arena *p_arena); DLAPI int32 Dowa_String_Pos_Find(const char *p_from, const char *p_value, const size_t from_length, const size_t value_length); DLAPI char *Dowa_String_Find(const char *p_from, const char *p_value, const size_t from_length, const size_t value_length); -DLAPI int32 Dowa_String_Pos_Find_Char(const char *p_from, int c, int32 from_len); -DLAPI char *Dowa_String_Find_Char(const char *p_from, int c, int32 from_len); -DLAPI char *Dowa_Int32ToString(uint32 value, char *p_buffer); +DLAPI int32 Dowa_String_Pos_Find_Char(const char *p_from, int c, int32 from_length); +DLAPI char *Dowa_String_Find_Char(const char *p_from, int c, int32 from_length); #endif