Use asserts in dbl_list
This commit is contained in:
		| @@ -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 | ||||
|     ) | ||||
|   | ||||
| @@ -1,6 +1,4 @@ | ||||
|   if (!list) {{ | ||||
|     return; | ||||
|   }} | ||||
|   assert(list != NULL); | ||||
|  | ||||
|   u64 count = list->node_count; | ||||
|   for (u64 i = 0; i < count; ++i) {{ | ||||
|   | ||||
| @@ -1,6 +1,4 @@ | ||||
|   if (index >= list->node_count) {{ | ||||
|     return NULL; | ||||
|   }} | ||||
|   assert(index < list->node_count); | ||||
|  | ||||
|   {NodeType} *output  = NULL; | ||||
|   {NodeType} *current = list->first; | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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; | ||||
|   }} | ||||
|  | ||||
|   | ||||
| @@ -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; | ||||
|   }} | ||||
|  | ||||
|   | ||||
| @@ -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); | ||||
|  | ||||
|   | ||||
| @@ -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); | ||||
|  | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -35,7 +35,7 @@ u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts) { | ||||
|   // MSVC Spectre mitigation warnings | ||||
|   const Str8Node *node = first_node; | ||||
|   u64 node_index       = 1; | ||||
|   bool running         = true; | ||||
|   bool running         = node_index < parts->node_count; | ||||
|   while (running && node->next) { | ||||
|     node = node->next; | ||||
|     if (node->item->size == 0) { | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -237,7 +237,7 @@ i64 wapp_str8_find(Str8RO *str, Str8RO substr) { | ||||
|   // NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of | ||||
|   // MSVC Spectre mitigation warnings | ||||
|   u64 char_index = 0; | ||||
|   bool running   = true; | ||||
|   bool running   = char_index < str->size; | ||||
|   while (running) { | ||||
|     const c8 *sub = str->buf + char_index; | ||||
|     if (memcmp(sub, substr.buf, substr.size) == 0) { | ||||
| @@ -259,7 +259,7 @@ i64 wapp_str8_rfind(Str8RO *str, Str8RO substr) { | ||||
|   // NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of | ||||
|   // MSVC Spectre mitigation warnings | ||||
|   i64 char_index = str->size - substr.size; | ||||
|   bool running   = true; | ||||
|   bool running   = char_index >= 0; | ||||
|   while (running) { | ||||
|     const c8 *sub = str->buf + char_index; | ||||
|     if (memcmp(sub, substr.buf, substr.size) == 0) { | ||||
| @@ -302,7 +302,7 @@ 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)); | ||||
|     if (node) { | ||||
|     if (node && before_str) { | ||||
|       node->item = before_str; | ||||
|       wapp_str8_list_push_back(output, node); | ||||
|     } | ||||
| @@ -317,7 +317,7 @@ 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)); | ||||
|   if (node) { | ||||
|   if (node && rest) { | ||||
|     node->item = rest; | ||||
|     wapp_str8_list_push_back(output, node); | ||||
|   } | ||||
| @@ -334,7 +334,7 @@ Str8List *wapp_str8_rsplit_with_max(const Allocator *allocator, Str8RO *str, Str | ||||
|   if (delimiter->size > str->size) { | ||||
|     Str8 *full     = wapp_str8_alloc_str8(allocator, str); | ||||
|     Str8Node *node = wapp_mem_allocator_alloc(allocator, sizeof(Str8Node)); | ||||
|     if (node) { | ||||
|     if (node && full) { | ||||
|       node->item = full; | ||||
|       wapp_str8_list_push_back(output, node); | ||||
|     } | ||||
| @@ -367,7 +367,7 @@ 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)); | ||||
|   if (node) { | ||||
|   if (node && rest) { | ||||
|     node->item = rest; | ||||
|     wapp_str8_list_push_front(output, node); | ||||
|   } | ||||
| @@ -386,7 +386,7 @@ Str8 *wapp_str8_join(const Allocator *allocator, const Str8List *list, Str8RO *d | ||||
|   // MSVC Spectre mitigation warnings | ||||
|   Str8Node *node; | ||||
|   u64 node_index = 0; | ||||
|   bool running   = true; | ||||
|   bool running   = node_index < list->node_count; | ||||
|   while (running) { | ||||
|     node = wapp_str8_list_get(list, node_index); | ||||
|     if (!node) { | ||||
| @@ -419,7 +419,7 @@ u64 wapp_str8_list_total_size(const Str8List *list) { | ||||
|   Str8Node* node; | ||||
|   u64 node_index = 0; | ||||
|   u64 output     = 0; | ||||
|   bool running   = true; | ||||
|   bool running   = node_index < list->node_count; | ||||
|   while (running) { | ||||
|       node = wapp_str8_list_get(list, node_index); | ||||
|       if (!node) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user