From ed3c71373307909d20f0ea44adf06dc7e433bc6e Mon Sep 17 00:00:00 2001 From: dx Date: Fri, 22 May 2020 21:13:57 +0100 Subject: ~array_init now uses pointer to an array pointer This means that the pointer that I allocate can actually be used. --- Converter/src/array.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Converter/src/array.c') diff --git a/Converter/src/array.c b/Converter/src/array.c index 442a4b5..650f31c 100644 --- a/Converter/src/array.c +++ b/Converter/src/array.c @@ -1,12 +1,12 @@ #include "../includes/array.h" #include -void array_init(array_t *arr) +void array_init(array_t **arr) { - arr = malloc(sizeof(*arr)); - arr->sz_used = 0; - arr->sz_allocated = 8; - arr->data = malloc(arr->sz_allocated); + (*arr) = malloc(sizeof(*arr)); + (*arr)->sz_used = 0; + (*arr)->sz_allocated = 8; + (*arr)->data = malloc((*arr)->sz_allocated); } void array_append(array_t *arr, void *data) -- cgit v1.2.3-13-gbd6f