44 Commits

Author SHA1 Message Date
b59aedad89 Add BasicString and StringView 2024-04-29 23:22:59 +01:00
3f5e3558b9 Add BasicString 2024-04-29 23:06:22 +01:00
bb2db0d30d Return StringUpdate from the dstr update functions 2024-04-29 22:55:40 +01:00
e75846a507 Update dstr to use Arena 2024-04-29 22:48:10 +01:00
05e56d67ea Reorganise the code 2024-04-29 21:42:33 +01:00
7164156c35 Simplify Arena 2024-04-28 22:59:37 +01:00
e67e1df9a5 Rename arena free functions 2024-04-28 22:04:23 +01:00
e206b4f4a6 Remove Allocator functions from Arena 2024-04-24 23:40:10 +01:00
05bfa73509 Revert "Simplify Arena allocator"
This reverts commit d4313fb8e4.
2024-04-24 23:18:19 +01:00
d4313fb8e4 Simplify Arena allocator 2024-04-24 23:10:55 +01:00
92db9206cc Remove complicated memory abstractions 2024-04-24 22:51:42 +01:00
6195b521f5 Set minimum capacity for arena 2024-04-21 23:59:00 +01:00
be64571b0e Pass allocator as const * 2024-03-31 17:29:23 +01:00
645686ae22 Remove unused variable 2024-03-31 17:05:04 +01:00
3f9a908860 Address some minor bugs in dstr 2024-03-31 17:00:16 +01:00
2e93bd794a Switch to using Allocator in dstr 2024-03-31 17:00:01 +01:00
39c88505bd Fix bug with libc allocator where memory was set to 0 on reallocation 2024-03-31 16:58:38 +01:00
970c588d66 Pass const Arena* to Allocator constuctor instead of Arena* 2024-03-25 07:52:49 +00:00
Abdelrahman Said
efe8a104de Add allocator functions 2024-03-24 21:06:41 +00:00
Abdelrahman Said
6f799c4330 Remove alloc_obj and pass double pointer to free function 2024-03-24 21:05:32 +00:00
Abdelrahman Said
8a58a1cc48 Implement Allocator wrapper for memory context 2024-03-24 20:30:14 +00:00
Abdelrahman Said
03d2a59948 Implement Allocator wrapper for Arena 2024-03-24 20:25:51 +00:00
Abdelrahman Said
5b8e9f8be6 Wrap libc memory functions in Allocator interface 2024-03-24 19:25:07 +00:00
Abdelrahman Said
9ec123c41b Start implementing allocator abstraction 2024-03-24 19:24:54 +00:00
Abdelrahman Said
7039b5437a Implement memory context realloc function 2024-03-24 19:24:36 +00:00
Abdelrahman Said
ca36e0dc35 Fix bug in the function that searches for the allocation header 2024-03-24 17:24:33 +00:00
Abdelrahman Said
3fdd897291 Implement realloc function for Arena 2024-03-24 14:57:21 +00:00
Abdelrahman Said
08703b465c Add arena allocation header 2024-03-24 13:55:13 +00:00
Abdelrahman Said
49ce26a6c2 Switch to using calloc instead of malloc 2024-03-24 11:25:52 +00:00
feada0b31c Add -O3 to compile flags 2024-03-24 08:10:40 +00:00
Abdelrahman Said
0c07437ef2 Implement memory context with main and temp arenas 2024-03-24 07:59:46 +00:00
Abdelrahman Said
063bc03974 Fix bug with clearing arena function 2024-03-24 07:49:49 +00:00
Abdelrahman Said
09af7ec734 Update .gitignore 2024-03-24 07:21:08 +00:00
Abdelrahman Said
04e86d355d Rename output name in compile script 2024-03-24 07:20:50 +00:00
Abdelrahman Said
7bfaf53d4e Return false when initialising arena with 0 capacity 2024-03-24 07:15:39 +00:00
Abdelrahman Said
958df4b55a Update .gitignore 2024-03-24 07:09:17 +00:00
Abdelrahman Said
9179f9beaa Ensure arena has been allocated before attempting to free 2024-03-24 06:37:02 +00:00
Abdelrahman Said
7aaeb91fe1 Update compile script 2024-03-24 06:21:22 +00:00
Abdelrahman Said
df4315cdcc Use echo instead of printf in compile script 2024-03-24 05:52:29 +00:00
Abdelrahman Said
b3a174f26c Update compile script 2024-03-24 05:45:13 +00:00
6fc0b2987e Add extern "C" to all header files 2024-03-21 23:06:27 +00:00
76222d31d4 Namespace all functions 2024-03-21 07:26:26 +00:00
7948d3fd1a Ensure arena is freed when initialisation fails 2024-02-24 23:01:26 +00:00
1094a9fefb Add comment for default alignment 2024-02-24 22:59:25 +00:00
16 changed files with 337 additions and 312 deletions

3
.gitignore vendored
View File

@@ -1,3 +1,4 @@
.cache
.vscode
compile_commands.json
libwizapp.so
libwapp.so

13
compile
View File

@@ -2,17 +2,12 @@
CC=clang
INCLUDE="\
-Ialiases \
-Icpath/include \
-Idstr/include \
$(find mem/include/ -type d | xargs -I{} printf "-I{} ") \
$(find src -type d | xargs -I{} echo -n "-I{} ") \
"
SRC="\
cpath/src/*.c \
dstr/src/*.c \
mem/src/*/*.c \
$(find src -type f -name *.c | xargs -I{} echo -n "{} ") \
"
CFLAGS="-shared -fPIC -Wall -Werror -pedantic"
OUT="libwizapp.so"
CFLAGS="-O3 -shared -fPIC -Wall -Werror -pedantic"
OUT="libwapp.so"
(set -x ; $CC $CFLAGS $INCLUDE $SRC -o $OUT)

View File

@@ -1,22 +0,0 @@
#ifndef DSTR_H
#define DSTR_H
#include "aliases.h"
typedef struct dstr String;
String *dstr_with_capacity(u64 capacity);
String *dstr_from_string(const char *str);
void dstr_update(String **dst, const char *src);
void dstr_free(String **str);
void dstr_concat(String **dst, const char *src);
void dstr_append(String **dst, char c);
void dstr_resize(String **str);
void dstr_clear(String *str);
void dstr_print(const String *str);
i64 dstr_find(const String *str, const char *substr);
u64 dstr_length(const String *str);
u64 dstr_capacity(const String *str);
const char *dstr_to_cstr(const String *str);
#endif // !DSTR_H

View File

@@ -1,219 +0,0 @@
#include "dstr.h"
#include "aliases.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Use this scalar to allocate extra memory in order to avoid having to
// constantly reallocate
#define CAPACITY_SCALAR 8
struct dstr {
u64 capacity;
u64 size;
char buf[];
};
String *dstr_with_capacity(u64 capacity) {
String *out = (String *)malloc(sizeof(String) + capacity + 1);
if (!out) {
return NULL;
}
out->capacity = capacity;
out->size = 0;
memset(out->buf, 0, capacity + 1);
return out;
}
String *dstr_from_string(const char *str) {
if (!str) {
return NULL;
}
u64 length = strlen(str);
u64 capacity = length * CAPACITY_SCALAR;
String *out = dstr_with_capacity(capacity);
if (!out) {
return NULL;
}
out->size = length;
strncpy(out->buf, str, length);
return out;
}
void dstr_update(String **dst, const char *src) {
if (!dst || !(*dst)) {
return;
}
u64 length = strlen(src);
String *str = *dst;
if (length <= str->capacity) {
memset(str->buf, 0, str->capacity);
str->size = length;
strncpy(str->buf, src, length);
} else {
u64 capacity = length * CAPACITY_SCALAR;
String *tmp = (String *)realloc(*dst, sizeof(String) + capacity + 1);
if (!tmp) {
return;
}
tmp->capacity = capacity;
tmp->size = length;
strncpy(tmp->buf, src, length);
*dst = tmp;
}
}
void dstr_free(String **str) {
if (!str || !(*str)) {
return;
}
free(*str);
*str = NULL;
}
void dstr_concat(String **dst, const char *src) {
if (!dst || !(*dst)) {
return;
}
u64 src_length = strlen(src);
if (src_length == 0) {
return;
}
u64 new_length = (*dst)->size + src_length;
char str[new_length + 1];
memset(str, 0, new_length + 1);
strncpy(str, (*dst)->buf, (*dst)->size);
strncat(str, src, src_length);
dstr_update(dst, str);
}
void dstr_append(String **dst, char c) {
if (!dst || !(*dst)) {
return;
}
u64 new_length = (*dst)->size + 1;
char str[new_length + 1];
memset(str, 0, new_length + 1);
strncpy(str, (*dst)->buf, (*dst)->size);
str[(*dst)->size] = c;
dstr_update(dst, str);
}
void dstr_resize(String **str) {
if (!str || !(*str)) {
return;
}
u64 capacity = (*str)->size;
String *tmp = (String *)realloc(*str, sizeof(String) + capacity + 1);
if (!tmp) {
return;
}
tmp->capacity = capacity;
*str = tmp;
}
void dstr_clear(String *str) {
if (!str || str->size == 0) {
return;
}
memset(str->buf, 0, str->capacity);
str->size = 0;
}
void dstr_print(const String *str) {
if (!str) {
return;
}
printf("%s\n", str->buf);
}
i64 dstr_find(const String *str, const char *substr) {
if (!str || !substr) {
return -1;
}
u64 substr_length = strlen(substr);
if (substr_length == 0 || substr_length > str->size) {
return -1;
}
char buf[substr_length + 1];
memset(buf, 0, substr_length + 1);
for (u64 i = 0; i < str->size; ++i) {
if (i + substr_length >= str->size) {
break;
}
for (u64 j = 0; j < substr_length; ++j) {
buf[j] = str->buf[i + j];
}
if (strcmp(buf, substr) == 0) {
return i;
}
}
return -1;
}
u64 dstr_length(const String *str) {
if (!str) {
return 0;
}
return str->size;
}
u64 dstr_capacity(const String *str) {
if (!str) {
return 0;
}
return str->capacity;
}
const char *dstr_to_cstr(const String *str) {
if (!str) {
return "";
}
return str->buf;
}

View File

@@ -1,15 +0,0 @@
#ifndef MEM_ARENA_H
#define MEM_ARENA_H
#include "aliases.h"
#include <stdbool.h>
typedef struct growing_arena Arena;
bool mem_arena_init(Arena **arena, u64 base_capacity);
void *mem_arena_alloc(Arena *arena, u64 size);
void *mem_arena_alloc_aligned(Arena *arena, u64 size, u64 alignment);
void mem_arena_clear(Arena *arena);
void mem_arena_free(Arena **arena);
#endif // !MEM_ARENA_H

View File

@@ -1,8 +0,0 @@
#ifndef MEM_UTILS_H
#define MEM_UTILS_H
#include "aliases.h"
void *mem_util_align_forward(void *ptr, u64 alignment);
#endif // !MEM_UTILS_H

View File

@@ -3,15 +3,23 @@
#include "aliases.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#define NUMPARTS(...) \
(sizeof((const char *[]){"", __VA_ARGS__}) / sizeof(const char *) - 1)
#define cpath_join_path(DST, ...) \
#define wapp_cpath_join_path(DST, ...) \
join_path(DST, NUMPARTS(__VA_ARGS__), __VA_ARGS__)
#define cpath_dirname(DST, PATH) dirup(DST, 1, PATH)
#define cpath_dirup(DST, COUNT, PATH) dirup(DST, COUNT, PATH)
#define wapp_cpath_dirname(DST, PATH) dirup(DST, 1, PATH)
#define wapp_cpath_dirup(DST, COUNT, PATH) dirup(DST, COUNT, PATH)
void join_path(char *dst, u64 count, ...);
void dirup(char *dst, u64 levels, const char *path);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // !PATH_UTILS_H

View File

@@ -6,9 +6,13 @@
#include <string.h>
#ifndef DEFAULT_ALIGNMENT
// Why 2 * sizeof(void *) instead of sizeof(void *)
// https://handmade.network/forums/t/6860-alignment_arena_allocator
#define DEFAULT_ALIGNMENT (2 * sizeof(void *))
#endif /* ifndef DEFAULT_ALIGNMENT */
#define ARENA_MINIMUM_CAPACITY 1024
typedef struct base_arena BaseArena;
struct base_arena {
u8 *buf;
@@ -28,31 +32,29 @@ internal bool base_arena_init(BaseArena *arena, u64 capacity);
internal void *base_arena_alloc_aligned(BaseArena *arena, u64 size,
u64 alignment);
internal void base_arena_clear(BaseArena *arena);
internal void base_arena_free(BaseArena *arena);
internal void base_arena_destroy(BaseArena *arena);
// PUBLIC API
bool mem_arena_init(Arena **arena, u64 base_capacity) {
if (!arena || *arena) {
bool wapp_mem_arena_init(Arena **arena, u64 base_capacity) {
if (!arena || *arena || base_capacity == 0) {
return false;
}
*arena = (Arena *)malloc(sizeof(Arena));
*arena = (Arena *)calloc(1, sizeof(Arena));
Arena *arena_ptr = *arena;
if (!arena_ptr) {
return false;
}
memset(arena_ptr, 0, sizeof(Arena));
arena_ptr->active_arena = (BaseArena *)malloc(sizeof(BaseArena));
arena_ptr->active_arena = (BaseArena *)calloc(1, sizeof(BaseArena));
if (!(arena_ptr->active_arena)) {
wapp_mem_arena_destroy(arena);
return false;
}
memset(arena_ptr->active_arena, 0, sizeof(BaseArena));
if (!base_arena_init(arena_ptr->active_arena, base_capacity)) {
wapp_mem_arena_destroy(arena);
return false;
}
@@ -62,11 +64,11 @@ bool mem_arena_init(Arena **arena, u64 base_capacity) {
return true;
}
void *mem_arena_alloc(Arena *arena, u64 size) {
return mem_arena_alloc_aligned(arena, size, DEFAULT_ALIGNMENT);
void *wapp_mem_arena_alloc(Arena *arena, u64 size) {
return wapp_mem_arena_alloc_aligned(arena, size, DEFAULT_ALIGNMENT);
}
void *mem_arena_alloc_aligned(Arena *arena, u64 size, u64 alignment) {
void *wapp_mem_arena_alloc_aligned(Arena *arena, u64 size, u64 alignment) {
if (!arena || !(arena->active_arena)) {
return NULL;
}
@@ -76,13 +78,11 @@ void *mem_arena_alloc_aligned(Arena *arena, u64 size, u64 alignment) {
if (arena->active_arena->next) {
arena->active_arena = arena->active_arena->next;
} else {
arena->active_arena->next = (BaseArena *)malloc(sizeof(BaseArena));
arena->active_arena->next = (BaseArena *)calloc(1, sizeof(BaseArena));
if (!(arena->active_arena->next)) {
return NULL;
}
memset(arena->active_arena->next, 0, sizeof(BaseArena));
if (!base_arena_init(arena->active_arena->next,
arena->initial_capacity)) {
free(arena->active_arena->next);
@@ -106,31 +106,32 @@ void *mem_arena_alloc_aligned(Arena *arena, u64 size, u64 alignment) {
return output;
}
void mem_arena_clear(Arena *arena) {
void wapp_mem_arena_clear(Arena *arena) {
if (!arena) {
return;
}
BaseArena *new_active = NULL;
BaseArena *last_active = NULL;
while (arena->active_arena) {
base_arena_clear(arena->active_arena);
last_active = arena->active_arena;
arena->active_arena = arena->active_arena->prev;
if (arena->active_arena) {
new_active = arena->active_arena;
}
}
arena->active_arena = new_active;
arena->active_arena = last_active;
}
void mem_arena_free(Arena **arena) {
void wapp_mem_arena_destroy(Arena **arena) {
if (!arena) {
return;
}
Arena *arena_ptr = *arena;
if (!arena_ptr) {
return;
}
BaseArena *current;
BaseArena *next;
@@ -140,7 +141,7 @@ void mem_arena_free(Arena **arena) {
while (current) {
next = current->next;
base_arena_free(current);
base_arena_destroy(current);
free(current);
current = next;
@@ -150,13 +151,13 @@ void mem_arena_free(Arena **arena) {
while (current) {
prev = current->prev;
base_arena_free(current);
base_arena_destroy(current);
free(current);
current = prev;
}
base_arena_free(arena_ptr->active_arena);
base_arena_destroy(arena_ptr->active_arena);
free(arena_ptr->active_arena);
arena_ptr->active_arena = NULL;
@@ -171,19 +172,19 @@ void mem_arena_free(Arena **arena) {
// INTERNAL FUNCTIONS
internal bool base_arena_init(BaseArena *arena, u64 capacity) {
if (!arena || arena->buf) {
if (!arena || arena->buf || capacity == 0) {
return false;
}
u64 alloc_size = sizeof(u8) * capacity;
u64 arena_capacity =
capacity >= ARENA_MINIMUM_CAPACITY ? capacity : ARENA_MINIMUM_CAPACITY;
arena->buf = (u8 *)malloc(alloc_size);
arena->buf = (u8 *)calloc(arena_capacity, sizeof(u8));
if (!(arena->buf)) {
return false;
}
memset(arena->buf, 0, alloc_size);
arena->capacity = capacity;
arena->capacity = arena_capacity;
arena->offset = arena->buf;
arena->prev = arena->next = NULL;
@@ -196,12 +197,14 @@ internal void *base_arena_alloc_aligned(BaseArena *arena, u64 size,
return NULL;
}
u8 *output = mem_util_align_forward((void *)(arena->offset), alignment);
u8 *alloc_start = arena->offset;
u8 *output = wapp_mem_util_align_forward((void *)alloc_start, alignment);
if (output + size >= arena->buf + arena->capacity) {
return NULL;
}
arena->offset += size;
arena->offset = output + size;
return (void *)output;
}
@@ -215,7 +218,7 @@ internal void base_arena_clear(BaseArena *arena) {
arena->offset = arena->buf;
}
internal void base_arena_free(BaseArena *arena) {
internal void base_arena_destroy(BaseArena *arena) {
if (!arena) {
return;
}

23
src/mem/arena/mem_arena.h Normal file
View File

@@ -0,0 +1,23 @@
#ifndef MEM_ARENA_H
#define MEM_ARENA_H
#include "aliases.h"
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
typedef struct growing_arena Arena;
bool wapp_mem_arena_init(Arena **arena, u64 base_capacity);
void *wapp_mem_arena_alloc(Arena *arena, u64 size);
void *wapp_mem_arena_alloc_aligned(Arena *arena, u64 size, u64 alignment);
void wapp_mem_arena_clear(Arena *arena);
void wapp_mem_arena_destroy(Arena **arena);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // !MEM_ARENA_H

View File

@@ -6,7 +6,7 @@
internal bool is_power_of_two(u64 num) { return (num & (num - 1)) == 0; }
void *mem_util_align_forward(void *ptr, u64 alignment) {
void *wapp_mem_util_align_forward(void *ptr, u64 alignment) {
if (!ptr) {
return NULL;
}

16
src/mem/util/mem_utils.h Normal file
View File

@@ -0,0 +1,16 @@
#ifndef MEM_UTILS_H
#define MEM_UTILS_H
#include "aliases.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
void *wapp_mem_util_align_forward(void *ptr, u64 alignment);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // !MEM_UTILS_H

View File

@@ -0,0 +1,34 @@
#ifndef BASIC_STRING_H
#define BASIC_STRING_H
#include "aliases.h"
#include <stdio.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
typedef struct bstr BasicString;
struct bstr {
u64 size;
const char *buf;
};
typedef struct strvw StringView;
struct strvw {
const u64 size;
const char *buf;
};
#define new_string(STR) \
{ .size = strlen(STR), .buf = STR }
#define wapp_bstr_new(STR) ((BasicString)new_string(STR))
#define wapp_strvw_new(STR) ((StringView)new_string(STR))
#define wapp_string_print(STR) (printf("%.*s\n", (i32)STR.size, STR.buf))
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // !BASIC_STRING_H

174
src/strings/dstr/dstr.c Normal file
View File

@@ -0,0 +1,174 @@
#include "dstr.h"
#include "aliases.h"
#include "mem_arena.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Use this scalar to allocate extra memory in order to avoid having to
// constantly reallocate
#define CAPACITY_SCALAR 8
#define MINIMUM_DSTR_CAPACITY 1024
struct dstr {
u64 capacity;
u64 size;
char buf[];
};
String *wapp_dstr_with_capacity(u64 capacity, Arena *arena) {
if (!arena) {
return NULL;
}
String *out =
(String *)wapp_mem_arena_alloc(arena, sizeof(String) + capacity + 1);
if (!out) {
return NULL;
}
out->capacity = capacity;
out->size = 0;
return out;
}
String *wapp_dstr_from_string(const char *str, Arena *arena) {
if (!str || !arena) {
return NULL;
}
u64 length = strlen(str);
u64 capacity = length * CAPACITY_SCALAR;
capacity =
capacity >= MINIMUM_DSTR_CAPACITY ? capacity : MINIMUM_DSTR_CAPACITY;
String *out = wapp_dstr_with_capacity(capacity, arena);
if (!out) {
return NULL;
}
out->size = length;
strncpy(out->buf, str, length + 1);
return out;
}
StringUpdate wapp_dstr_update(String **dst, const char *src, Arena *arena) {
if (!dst || !(*dst)) {
return (StringUpdate){.updated = false, .str = *dst};
}
u64 length = strlen(src);
String *str = *dst;
if (length >= str->capacity) {
if (!arena) {
return (StringUpdate){.updated = false, .str = *dst};
}
String *new_str = wapp_dstr_from_string(src, arena);
if (!new_str) {
return (StringUpdate){.updated = false, .str = *dst};
}
return (StringUpdate){.updated = true, .str = new_str};
}
memset(str->buf, 0, str->capacity);
str->size = length;
strncpy(str->buf, src, length + 1);
return (StringUpdate){.updated = true, .str = *dst};
}
StringUpdate wapp_dstr_concat(String **dst, const char *src, Arena *arena) {
if (!dst || !(*dst)) {
return (StringUpdate){.updated = false, .str = *dst};
}
u64 src_length = strlen(src);
if (src_length == 0) {
return (StringUpdate){.updated = false, .str = *dst};
}
u64 new_length = (*dst)->size + src_length;
char str[new_length + 1];
memset(str, 0, new_length + 1);
strncpy(str, (*dst)->buf, (*dst)->size);
strncat(str, src, new_length + 1 - (*dst)->size);
return wapp_dstr_update(dst, str, arena);
}
void wapp_dstr_clear(String *str) {
if (!str || str->size == 0) {
return;
}
memset(str->buf, 0, str->capacity);
str->size = 0;
}
void wapp_dstr_print(const String *str) {
if (!str) {
return;
}
printf("%.*s\n", (i32)str->size, str->buf);
}
i64 wapp_dstr_find(const String *str, const char *substr) {
if (!str || !substr) {
return -1;
}
u64 substr_length = strlen(substr);
if (substr_length == 0 || substr_length > str->size) {
return -1;
}
const char *s1;
for (u64 i = 0; i < str->size; ++i) {
if (i + substr_length > str->size) {
break;
}
s1 = &(str->buf[i]);
if (strncmp(s1, substr, substr_length) == 0) {
return i;
}
}
return -1;
}
u64 wapp_dstr_length(const String *str) {
if (!str) {
return 0;
}
return str->size;
}
u64 wapp_dstr_capacity(const String *str) {
if (!str) {
return 0;
}
return str->capacity;
}
const char *wapp_dstr_to_cstr(const String *str) {
if (!str) {
return "";
}
return str->buf;
}

35
src/strings/dstr/dstr.h Normal file
View File

@@ -0,0 +1,35 @@
#ifndef DSTR_H
#define DSTR_H
#include "aliases.h"
#include "mem_arena.h"
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
typedef struct dstr String;
typedef struct string_update StringUpdate;
struct string_update {
bool updated;
String *str;
};
String *wapp_dstr_with_capacity(u64 capacity, Arena *arena);
String *wapp_dstr_from_string(const char *str, Arena *arena);
StringUpdate wapp_dstr_update(String **dst, const char *src, Arena *arena);
StringUpdate wapp_dstr_concat(String **dst, const char *src, Arena *arena);
void wapp_dstr_clear(String *str);
void wapp_dstr_print(const String *str);
i64 wapp_dstr_find(const String *str, const char *substr);
u64 wapp_dstr_length(const String *str);
u64 wapp_dstr_capacity(const String *str);
const char *wapp_dstr_to_cstr(const String *str);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // !DSTR_H