Use asserts in dbl_list

This commit is contained in:
2025-05-05 19:55:42 +01:00
parent 175f627f93
commit cac66b9dbb
12 changed files with 288 additions and 430 deletions

View File

@@ -93,7 +93,11 @@ def make_dbl_list(user_datatypes: Dict[CDataType, DblListData] = {}):
source = CSource(
name=header.name,
decl_types=[*common_decl_types],
includes=[CInclude(header, local=True, same_dir=True), CInclude(header="stddef.h")],
includes=[
CInclude(header, local=True, same_dir=True),
CInclude(header="stddef.h"),
CInclude(header="assert.h"),
],
internal_funcs=[],
funcs=header.funcs
)

View File

@@ -1,6 +1,4 @@
if (!list) {{
return;
}}
assert(list != NULL);
u64 count = list->node_count;
for (u64 i = 0; i < count; ++i) {{

View File

@@ -1,6 +1,4 @@
if (index >= list->node_count) {{
return NULL;
}}
assert(index < list->node_count);
{NodeType} *output = NULL;
{NodeType} *current = list->first;

View File

@@ -1,6 +1,4 @@
if (!list || !node || !(node->item)) {{
return;
}}
assert(list != NULL && node != NULL && (node->item) != NULL);
if (index == 0) {{
wapp_{Tlower}_list_push_front(list, node);

View File

@@ -1,6 +1,8 @@
assert(list != NULL);
{NodeType} *output = NULL;
if (!list || list->node_count == 0) {{
if (list->node_count == 0) {{
goto RETURN_{Tupper}_LIST_POP_BACK;
}}

View File

@@ -1,6 +1,8 @@
assert(list != NULL);
{NodeType} *output = NULL;
if (!list || list->node_count == 0) {{
if (list->node_count == 0) {{
goto RETURN_{Tupper}_LIST_POP_FRONT;
}}

View File

@@ -1,6 +1,4 @@
if (!list || !node || !(node->item)) {{
return;
}}
assert(list != NULL && node != NULL && (node->item) != NULL);
{ListType} node_list = {Tlower}_node_to_list(node);

View File

@@ -1,6 +1,4 @@
if (!list || !node || !(node->item)) {{
return;
}}
assert(list != NULL && node != NULL && (node->item) != NULL);
{ListType} node_list = {Tlower}_node_to_list(node);

View File

@@ -1,7 +1,6 @@
assert(list != NULL);
{NodeType} *output = NULL;
if (!list) {{
goto RETURN_{Tupper}_LIST_REMOVE;
}}
if (index == 0) {{
output = wapp_{Tlower}_list_pop_front(list);