aboutsummaryrefslogtreecommitdiff
path: root/src/dynalloc.c
diff options
context:
space:
mode:
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);
+}