No codegen doubly-linked list (#8)

Reviewed-on: #8
Co-authored-by: Abdelrahman <said.abdelrahman89@gmail.com>
Co-committed-by: Abdelrahman <said.abdelrahman89@gmail.com>
This commit was merged in pull request #8.
This commit is contained in:
2025-12-17 03:53:13 +00:00
committed by Abdelrahman Said
parent 4b95a681d4
commit 4ea30f0762
43 changed files with 551 additions and 8249 deletions

View File

@@ -333,14 +333,14 @@ i64 wapp_str8_rfind(Str8RO *str, Str8RO substr) {
Str8List *wapp_str8_split_with_max(const Allocator *allocator, Str8RO *str, Str8RO *delimiter, i64 max_splits) {
wapp_debug_assert(allocator != NULL && str != NULL && delimiter != NULL, "`allocator`, `str` and `delimiter` should not be NULL");
Str8List *output = wapp_mem_allocator_alloc(allocator, sizeof(Str8List));
Str8List *output = wapp_dbl_list_alloc(Str8, Str8List, allocator);
if (delimiter->size > str->size) {
Str8 *full = wapp_str8_alloc_str8(allocator, str);
Str8Node *node = wapp_mem_allocator_alloc(allocator, sizeof(Str8Node));
Str8Node *node = wapp_dbl_list_node_alloc(Str8, Str8Node, allocator);
if (node) {
node->item = full;
wapp_str8_list_push_back(output, node);
wapp_dbl_list_push_back(Str8, output, node);
}
goto RETURN_STR8_SPLIT;
@@ -358,10 +358,10 @@ Str8List *wapp_str8_split_with_max(const Allocator *allocator, Str8RO *str, Str8
}
before_str = wapp_str8_alloc_substr(allocator, str, start, start + end);
Str8Node *node = wapp_mem_allocator_alloc(allocator, sizeof(Str8Node));
Str8Node *node = wapp_dbl_list_node_alloc(Str8, Str8Node, allocator);
if (node && before_str) {
node->item = before_str;
wapp_str8_list_push_back(output, node);
wapp_dbl_list_push_back(Str8, output, node);
}
wapp_mem_allocator_free(allocator, (void **)&rest, sizeof(Str8));
@@ -373,10 +373,10 @@ Str8List *wapp_str8_split_with_max(const Allocator *allocator, Str8RO *str, Str8
// Ensure the last part of the string after the delimiter is added to the list
rest = wapp_str8_alloc_substr(allocator, str, start, str->size);
Str8Node *node = wapp_mem_allocator_alloc(allocator, sizeof(Str8Node));
Str8Node *node = wapp_dbl_list_node_alloc(Str8, Str8Node, allocator);
if (node && rest) {
node->item = rest;
wapp_str8_list_push_back(output, node);
wapp_dbl_list_push_back(Str8, output, node);
}
RETURN_STR8_SPLIT:
@@ -386,14 +386,14 @@ RETURN_STR8_SPLIT:
Str8List *wapp_str8_rsplit_with_max(const Allocator *allocator, Str8RO *str, Str8RO *delimiter, i64 max_splits) {
wapp_debug_assert(allocator != NULL && str != NULL && delimiter != NULL, "`allocator`, `str` and `delimiter` should not be NULL");
Str8List *output = wapp_mem_allocator_alloc(allocator, sizeof(Str8List));
Str8List *output = wapp_dbl_list_alloc(Str8, Str8List, allocator);
if (delimiter->size > str->size) {
Str8 *full = wapp_str8_alloc_str8(allocator, str);
Str8Node *node = wapp_mem_allocator_alloc(allocator, sizeof(Str8Node));
Str8Node *node = wapp_dbl_list_node_alloc(Str8, Str8Node, allocator);
if (node && full) {
node->item = full;
wapp_str8_list_push_back(output, node);
wapp_dbl_list_push_back(Str8, output, node);
}
goto RETURN_STR8_SPLIT;
@@ -410,10 +410,10 @@ Str8List *wapp_str8_rsplit_with_max(const Allocator *allocator, Str8RO *str, Str
}
after_str = wapp_str8_alloc_substr(allocator, rest, end + delimiter->size, str->size);
Str8Node *node = wapp_mem_allocator_alloc(allocator, sizeof(Str8Node));
Str8Node *node = wapp_dbl_list_node_alloc(Str8, Str8Node, allocator);
if (node) {
node->item = after_str;
wapp_str8_list_push_front(output, node);
wapp_dbl_list_push_front(Str8, output, node);
}
wapp_mem_allocator_free(allocator, (void **)&rest, sizeof(Str8));
@@ -423,10 +423,10 @@ Str8List *wapp_str8_rsplit_with_max(const Allocator *allocator, Str8RO *str, Str
}
rest = wapp_str8_alloc_substr(allocator, str, 0, rest->size);
Str8Node *node = wapp_mem_allocator_alloc(allocator, sizeof(Str8Node));
Str8Node *node = wapp_dbl_list_node_alloc(Str8, Str8Node, allocator);
if (node && rest) {
node->item = rest;
wapp_str8_list_push_front(output, node);
wapp_dbl_list_push_front(Str8, output, node);
}
RETURN_STR8_SPLIT:
@@ -445,7 +445,7 @@ Str8 *wapp_str8_join(const Allocator *allocator, const Str8List *list, Str8RO *d
u64 node_index = 0;
b8 running = node_index < list->node_count;
while (running) {
node = wapp_str8_list_get(list, node_index);
node = wapp_dbl_list_get(Str8, Str8Node, list, node_index);
if (!node) {
break;
}
@@ -478,7 +478,7 @@ u64 wapp_str8_list_total_size(const Str8List *list) {
u64 output = 0;
b8 running = node_index < list->node_count;
while (running) {
node = wapp_str8_list_get(list, node_index);
node = wapp_dbl_list_get(Str8, Str8Node, list, node_index);
if (!node) {
break;
}