From 0d249b1d47a7f84cfe5f09ad070d1affd26566da Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 28 Apr 2026 14:06:44 +0300 Subject: feat!: Refactor using MemoryManager The idea is to provide a universal memory management "API", through which you allocate and deallocate. This allows our implementations (for String and Vector) to be more generic. It does also allow usage of different allocators depending on situation. --- String.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'String.h') diff --git a/String.h b/String.h index 9be9195..16f1990 100644 --- a/String.h +++ b/String.h @@ -1,25 +1,23 @@ #ifndef _STRING #define _STRING -#include "BumpAlloc.h" +#include "MemoryManager.h" +#include typedef char* String; -String S_new(BumpArena b, const char* str); -String S_newlen(BumpArena b, usize length); -String S_dup(BumpArena b, String s); -String S_concat(BumpArena b, ...); -String S_printf(BumpArena b, const char* fmt, ...); +String S_new(MemoryManager *mm, const char* str); +String S_newlen(MemoryManager *mm, usize length); +String S_dup(MemoryManager *mm, String s); +String S_vconcat(MemoryManager *mm, va_list args); +String S_concat(MemoryManager *mm, ...); +String S_vprintf(MemoryManager *mm, const char* fmt, va_list args); +String S_printf(MemoryManager *mm, const char* fmt, ...); usize S_length(String s); -Result S_append(String s, const char* str); -Result S_prepend(String s, const char* str); +Result S_append(String *s, const char* str); +Result S_prepend(String *s, const char* str); usize S_find(String s, char c); - -String SG_new(const char* str); -String SG_newlen(usize length); -String SG_dup(String s); -String SG_concat(const char* str, ...); -String SG_printf(const char* fmt, ...); +Result S_free(String s); #endif /* _STRING */ -- cgit v1.2.3