diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-02-17 11:41:23 +0100 |
---|---|---|
committer | gabrielgio <gabrielgio@workstation.lan> | 2024-02-17 16:48:54 +0100 |
commit | d102e028aee6571c0fd9dfd4074cfb3c15f4594e (patch) | |
tree | e0f3bdadc96019de0a7576ea591f8b304a962e67 /list.c | |
parent | c573d3b7954296d95a0f8a79b8ac2ca261d86a02 (diff) | |
download | dict-d102e028aee6571c0fd9dfd4074cfb3c15f4594e.tar.gz dict-d102e028aee6571c0fd9dfd4074cfb3c15f4594e.tar.bz2 dict-d102e028aee6571c0fd9dfd4074cfb3c15f4594e.zip |
ref: Refactor newer folder structure
Create a lib dict and importer project.
* dict: holds the main application
* importer: code to read from source to a common database.
* lib: shared code
Diffstat (limited to 'list.c')
-rw-r--r-- | list.c | 44 |
1 files changed, 0 insertions, 44 deletions
@@ -1,44 +0,0 @@ -#include "list.h" -#include <stdlib.h> - -LIST* list_add(LIST* list, void* item) -{ - - if (list == NULL) - { - list = (LIST*)malloc(sizeof(LIST)); - list->size = 0; - list->list = (void**)malloc(sizeof(0)); - - } - - list->size ++; - void** new_list = (void**)reallocarray(list->list, list->size, sizeof(void*)); - - new_list[list->size-1] = item; - list->list = new_list; - - return list; - -} - -LIST* list_remove(LIST* list, unsigned int pos) -{ - for(unsigned int i = pos; i < list->size - 1; i++) - list->list[i] = list->list[i + 1]; - - list->size--; - - void** new_list = reallocarray(list->list, list->size, sizeof(void*)); - list->list = new_list; - - return list; -} - -void list_free(LIST* list) { - for (unsigned int x = 0; x < list->size; x++) - free(list->list[x]); - - free(list->list); - free(list); -} |