Change boolean size to 1 byte
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
wapp_intern VoidPList void_ptr_node_to_list(VoidPNode *node);
|
||||
wapp_intern Str8List str8_node_to_list(Str8Node *node);
|
||||
wapp_intern B32List b32_node_to_list(B32Node *node);
|
||||
wapp_intern B8List b8_node_to_list(B8Node *node);
|
||||
wapp_intern CharList char_node_to_list(CharNode *node);
|
||||
wapp_intern C8List c8_node_to_list(C8Node *node);
|
||||
wapp_intern C16List c16_node_to_list(C16Node *node);
|
||||
@@ -375,11 +375,11 @@ void wapp_str8_list_empty(Str8List *list) {
|
||||
}
|
||||
}
|
||||
|
||||
B32Node *wapp_b32_list_get(const B32List *list, u64 index) {
|
||||
B8Node *wapp_b8_list_get(const B8List *list, u64 index) {
|
||||
wapp_runtime_assert(index < list->node_count, "`index` is out of bounds");
|
||||
|
||||
B32Node *output = NULL;
|
||||
B32Node *current = list->first;
|
||||
B8Node *output = NULL;
|
||||
B8Node *current = list->first;
|
||||
for (u64 i = 1; i <= index; ++i) {
|
||||
current = current->next;
|
||||
}
|
||||
@@ -389,10 +389,10 @@ B32Node *wapp_b32_list_get(const B32List *list, u64 index) {
|
||||
return output;
|
||||
}
|
||||
|
||||
void wapp_b32_list_push_front(B32List *list, B32Node *node) {
|
||||
void wapp_b8_list_push_front(B8List *list, B8Node *node) {
|
||||
wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL");
|
||||
|
||||
B32List node_list = b32_node_to_list(node);
|
||||
B8List node_list = b8_node_to_list(node);
|
||||
|
||||
if (list->node_count == 0) {
|
||||
*list = node_list;
|
||||
@@ -401,7 +401,7 @@ void wapp_b32_list_push_front(B32List *list, B32Node *node) {
|
||||
|
||||
list->node_count += node_list.node_count;
|
||||
|
||||
B32Node *first = list->first;
|
||||
B8Node *first = list->first;
|
||||
if (first) {
|
||||
first->prev = node_list.last;
|
||||
}
|
||||
@@ -410,10 +410,10 @@ void wapp_b32_list_push_front(B32List *list, B32Node *node) {
|
||||
node_list.last->next = first;
|
||||
}
|
||||
|
||||
void wapp_b32_list_push_back(B32List *list, B32Node *node) {
|
||||
void wapp_b8_list_push_back(B8List *list, B8Node *node) {
|
||||
wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL");
|
||||
|
||||
B32List node_list = b32_node_to_list(node);
|
||||
B8List node_list = b8_node_to_list(node);
|
||||
|
||||
if (list->node_count == 0) {
|
||||
*list = node_list;
|
||||
@@ -422,7 +422,7 @@ void wapp_b32_list_push_back(B32List *list, B32Node *node) {
|
||||
|
||||
list->node_count += node_list.node_count;
|
||||
|
||||
B32Node *last = list->last;
|
||||
B8Node *last = list->last;
|
||||
if (last) {
|
||||
last->next = node_list.first;
|
||||
}
|
||||
@@ -431,27 +431,27 @@ void wapp_b32_list_push_back(B32List *list, B32Node *node) {
|
||||
node_list.first->prev = last;
|
||||
}
|
||||
|
||||
void wapp_b32_list_insert(B32List *list, B32Node *node, u64 index) {
|
||||
void wapp_b8_list_insert(B8List *list, B8Node *node, u64 index) {
|
||||
wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL");
|
||||
|
||||
if (index == 0) {
|
||||
wapp_b32_list_push_front(list, node);
|
||||
wapp_b8_list_push_front(list, node);
|
||||
return;
|
||||
} else if (index == list->node_count) {
|
||||
wapp_b32_list_push_back(list, node);
|
||||
wapp_b8_list_push_back(list, node);
|
||||
return;
|
||||
}
|
||||
|
||||
B32Node *dst_node = wapp_b32_list_get(list, index);
|
||||
B8Node *dst_node = wapp_b8_list_get(list, index);
|
||||
if (!dst_node) {
|
||||
return;
|
||||
}
|
||||
|
||||
B32List node_list = b32_node_to_list(node);
|
||||
B8List node_list = b8_node_to_list(node);
|
||||
|
||||
list->node_count += node_list.node_count;
|
||||
|
||||
B32Node *prev = dst_node->prev;
|
||||
B8Node *prev = dst_node->prev;
|
||||
|
||||
dst_node->prev = node_list.last;
|
||||
prev->next = node_list.first;
|
||||
@@ -460,20 +460,20 @@ void wapp_b32_list_insert(B32List *list, B32Node *node, u64 index) {
|
||||
node_list.last->next = dst_node;
|
||||
}
|
||||
|
||||
B32Node *wapp_b32_list_pop_front(B32List *list) {
|
||||
B8Node *wapp_b8_list_pop_front(B8List *list) {
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
|
||||
B32Node *output = NULL;
|
||||
B8Node *output = NULL;
|
||||
|
||||
if (list->node_count == 0) {
|
||||
goto RETURN_B32_LIST_POP_FRONT;
|
||||
goto RETURN_B8_LIST_POP_FRONT;
|
||||
}
|
||||
|
||||
output = list->first;
|
||||
|
||||
if (list->node_count == 1) {
|
||||
*list = (B32List){0};
|
||||
goto RETURN_B32_LIST_POP_FRONT;
|
||||
*list = (B8List){0};
|
||||
goto RETURN_B8_LIST_POP_FRONT;
|
||||
}
|
||||
|
||||
--(list->node_count);
|
||||
@@ -481,24 +481,24 @@ B32Node *wapp_b32_list_pop_front(B32List *list) {
|
||||
|
||||
output->prev = output->next = NULL;
|
||||
|
||||
RETURN_B32_LIST_POP_FRONT:
|
||||
RETURN_B8_LIST_POP_FRONT:
|
||||
return output;
|
||||
}
|
||||
|
||||
B32Node *wapp_b32_list_pop_back(B32List *list) {
|
||||
B8Node *wapp_b8_list_pop_back(B8List *list) {
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
|
||||
B32Node *output = NULL;
|
||||
B8Node *output = NULL;
|
||||
|
||||
if (list->node_count == 0) {
|
||||
goto RETURN_B32_LIST_POP_BACK;
|
||||
goto RETURN_B8_LIST_POP_BACK;
|
||||
}
|
||||
|
||||
output = list->last;
|
||||
|
||||
if (list->node_count == 1) {
|
||||
*list = (B32List){0};
|
||||
goto RETURN_B32_LIST_POP_BACK;
|
||||
*list = (B8List){0};
|
||||
goto RETURN_B8_LIST_POP_BACK;
|
||||
}
|
||||
|
||||
--(list->node_count);
|
||||
@@ -506,26 +506,26 @@ B32Node *wapp_b32_list_pop_back(B32List *list) {
|
||||
|
||||
output->prev = output->next = NULL;
|
||||
|
||||
RETURN_B32_LIST_POP_BACK:
|
||||
RETURN_B8_LIST_POP_BACK:
|
||||
return output;
|
||||
}
|
||||
|
||||
B32Node *wapp_b32_list_remove(B32List *list, u64 index) {
|
||||
B8Node *wapp_b8_list_remove(B8List *list, u64 index) {
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
|
||||
B32Node *output = NULL;
|
||||
B8Node *output = NULL;
|
||||
|
||||
if (index == 0) {
|
||||
output = wapp_b32_list_pop_front(list);
|
||||
goto RETURN_B32_LIST_REMOVE;
|
||||
output = wapp_b8_list_pop_front(list);
|
||||
goto RETURN_B8_LIST_REMOVE;
|
||||
} else if (index == list->node_count) {
|
||||
output = wapp_b32_list_pop_back(list);
|
||||
goto RETURN_B32_LIST_REMOVE;
|
||||
output = wapp_b8_list_pop_back(list);
|
||||
goto RETURN_B8_LIST_REMOVE;
|
||||
}
|
||||
|
||||
output = wapp_b32_list_get(list, index);
|
||||
output = wapp_b8_list_get(list, index);
|
||||
if (!output) {
|
||||
goto RETURN_B32_LIST_REMOVE;
|
||||
goto RETURN_B8_LIST_REMOVE;
|
||||
}
|
||||
|
||||
output->prev->next = output->next;
|
||||
@@ -535,16 +535,16 @@ B32Node *wapp_b32_list_remove(B32List *list, u64 index) {
|
||||
|
||||
output->prev = output->next = NULL;
|
||||
|
||||
RETURN_B32_LIST_REMOVE:
|
||||
RETURN_B8_LIST_REMOVE:
|
||||
return output;
|
||||
}
|
||||
|
||||
void wapp_b32_list_empty(B32List *list) {
|
||||
void wapp_b8_list_empty(B8List *list) {
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
|
||||
u64 count = list->node_count;
|
||||
for (u64 i = 0; i < count; ++i) {
|
||||
wapp_b32_list_pop_back(list);
|
||||
wapp_b8_list_pop_back(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3521,8 +3521,8 @@ wapp_intern Str8List str8_node_to_list(Str8Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
wapp_intern B32List b32_node_to_list(B32Node *node) {
|
||||
B32List output = {.first = node, .last = node, .node_count = 1};
|
||||
wapp_intern B8List b8_node_to_list(B8Node *node) {
|
||||
B8List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
output.first = output.first->prev;
|
||||
|
||||
Reference in New Issue
Block a user