Update dbl_list functionality

This commit is contained in:
Abdelrahman Said
2025-04-16 00:42:20 +01:00
parent 778a4da092
commit 31373eba03
5 changed files with 68 additions and 67 deletions

View File

@@ -32,18 +32,19 @@ BEGIN_C_LINKAGE
DBL_LIST_DECL(void);
#define wapp_dbl_list_node_from_item(T, ITEM_PTR) ((DBL_NODE(T)){ .item = ITEM_PTR })
#define wapp_dbl_list_node_from_item(T, ITEM_PTR) \
((DBL_NODE(T)){ .item = ITEM_PTR })
#define wapp_dbl_list_get(T, LIST_PTR, INDEX) \
(DBL_NODE(T)*)_dbl_list_get(CAST_LIST_PTR(LIST_PTR), INDEX)
#define wapp_dbl_list_push_front(T, LIST_PTR, NODE_PTR) \
#define wapp_dbl_list_push_front(LIST_PTR, NODE_PTR) \
_dbl_list_push_front(CAST_LIST_PTR(LIST_PTR), CAST_NODE_PTR(NODE_PTR))
#define wapp_dbl_list_push_back(T, LIST_PTR, NODE_PTR) \
#define wapp_dbl_list_push_back(LIST_PTR, NODE_PTR) \
_dbl_list_push_back(CAST_LIST_PTR(LIST_PTR), CAST_NODE_PTR(NODE_PTR))
#define wapp_dbl_list_insert(T, LIST_PTR, NODE_PTR, INDEX) \
#define wapp_dbl_list_insert(LIST_PTR, NODE_PTR, INDEX) \
_dbl_list_insert(CAST_LIST_PTR(LIST_PTR), CAST_NODE_PTR(NODE_PTR), INDEX)
#define wapp_dbl_list_pop_front(T, LIST_PTR) \
@@ -55,7 +56,7 @@ DBL_LIST_DECL(void);
#define wapp_dbl_list_remove(T, LIST_PTR, INDEX) \
(DBL_NODE(T)*)_dbl_list_remove(CAST_LIST_PTR(LIST_PTR), INDEX)
#define wapp_dbl_list_empty(T, LIST_PTR) \
#define wapp_dbl_list_empty(LIST_PTR) \
_dbl_list_empty(CAST_LIST_PTR(LIST_PTR))
DBL_NODE(void) *_dbl_list_get(const DBL_LIST(void) *list, u64 index);

View File

@@ -314,7 +314,7 @@ DBL_LIST(Str8) *wapp_str8_split_with_max(const Allocator *allocator, Str8RO *str
DBL_NODE(Str8) *node = wapp_mem_allocator_alloc(allocator, sizeof(DBL_NODE(Str8)));
if (node) {
node->item = full;
wapp_dbl_list_push_back(Str8, output, node);
wapp_dbl_list_push_back(output, node);
}
goto RETURN_STR8_SPLIT;
@@ -335,7 +335,7 @@ DBL_LIST(Str8) *wapp_str8_split_with_max(const Allocator *allocator, Str8RO *str
DBL_NODE(Str8) *node = wapp_mem_allocator_alloc(allocator, sizeof(DBL_NODE(Str8)));
if (node) {
node->item = before_str;
wapp_dbl_list_push_back(Str8, output, node);
wapp_dbl_list_push_back(output, node);
}
wapp_mem_allocator_free(allocator, (void **)&rest, sizeof(Str8));
@@ -350,7 +350,7 @@ DBL_LIST(Str8) *wapp_str8_split_with_max(const Allocator *allocator, Str8RO *str
DBL_NODE(Str8) *node = wapp_mem_allocator_alloc(allocator, sizeof(DBL_NODE(Str8)));
if (node) {
node->item = rest;
wapp_dbl_list_push_back(Str8, output, node);
wapp_dbl_list_push_back(output, node);
}
RETURN_STR8_SPLIT:
@@ -369,7 +369,7 @@ DBL_LIST(Str8) *wapp_str8_rsplit_with_max(const Allocator *allocator, Str8RO *st
DBL_NODE(Str8) *node = wapp_mem_allocator_alloc(allocator, sizeof(DBL_NODE(Str8)));
if (node) {
node->item = full;
wapp_dbl_list_push_back(Str8, output, node);
wapp_dbl_list_push_back(output, node);
}
goto RETURN_STR8_SPLIT;
@@ -389,7 +389,7 @@ DBL_LIST(Str8) *wapp_str8_rsplit_with_max(const Allocator *allocator, Str8RO *st
DBL_NODE(Str8) *node = wapp_mem_allocator_alloc(allocator, sizeof(DBL_NODE(Str8)));
if (node) {
node->item = after_str;
wapp_dbl_list_push_front(Str8, output, node);
wapp_dbl_list_push_front(output, node);
}
wapp_mem_allocator_free(allocator, (void **)&rest, sizeof(Str8));
@@ -402,7 +402,7 @@ DBL_LIST(Str8) *wapp_str8_rsplit_with_max(const Allocator *allocator, Str8RO *st
DBL_NODE(Str8) *node = wapp_mem_allocator_alloc(allocator, sizeof(DBL_NODE(Str8)));
if (node) {
node->item = rest;
wapp_dbl_list_push_front(Str8, output, node);
wapp_dbl_list_push_front(output, node);
}
RETURN_STR8_SPLIT: