From 567e0df2434b270411d3356b8e362fc881113335 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Sat, 29 Aug 2020 14:05:22 +0200 Subject: first working --- src/dynalloc.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/dynalloc.c (limited to 'src/dynalloc.c') diff --git a/src/dynalloc.c b/src/dynalloc.c new file mode 100644 index 0000000..ecce3e7 --- /dev/null +++ b/src/dynalloc.c @@ -0,0 +1,22 @@ +/* + * src/dynalloc.c + * (c) 2020 Jonas Gunz + * License: MIT +*/ +#include "dynalloc.h" + +void** dynalloc_2d_array ( unsigned int _x, unsigned int _y, unsigned int _sizeof ) { + void** ret = NULL; + + ret = malloc ( _x * sizeof ( void* ) ); + for ( int i = 0; i < _x; i++ ) + ret[i] = malloc ( _y * _sizeof ); + + return ret; +} + +void dynalloc_2d_array_free ( unsigned int _x, unsigned int _y, void** _array ) { + for ( int i = 0; i < _x; i++ ) + free ( _array[i] ); + free(_array); +} -- cgit v1.2.3