wizapp-stdlib/codegen/dbl_list/snippets/list_remove
Abdelrahman Said 3c32b247c0 Upgrade codegen
2025-04-17 09:03:30 +01:00

28 lines
630 B
Plaintext

{Ttitle}Node *output = NULL;
if (!list) {{
goto RETURN_{Tupper}_LIST_REMOVE;
}}
if (index == 0) {{
output = wapp_{Tlower}_list_pop_front(list);
goto RETURN_{Tupper}_LIST_REMOVE;
}} else if (index == list->node_count) {{
output = wapp_{Tlower}_list_pop_back(list);
goto RETURN_{Tupper}_LIST_REMOVE;
}}
output = wapp_{Tlower}_list_get(list, index);
if (!output) {{
goto RETURN_{Tupper}_LIST_REMOVE;
}}
output->prev->next = output->next;
output->next->prev = output->prev;
--(list->node_count);
output->prev = output->next = NULL;
RETURN_{Tupper}_LIST_REMOVE:
return output;