aboutsummaryrefslogtreecommitdiff
path: root/src/dynalloc.c
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2020-08-29 14:05:22 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2020-08-29 14:05:22 +0200
commit567e0df2434b270411d3356b8e362fc881113335 (patch)
tree843da4160e3001bdd9f792d52a21f31c485f5215 /src/dynalloc.c
parent57b73d286ad68a71547cdfbb31c772fb46c96c67 (diff)
downloadAsciiMap-567e0df2434b270411d3356b8e362fc881113335.tar.gz
first working
Diffstat (limited to 'src/dynalloc.c')
-rw-r--r--src/dynalloc.c22
1 files changed, 22 insertions, 0 deletions
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 <himself@jonasgunz.de>
+ * 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);
+}