]> git.tdb.fi Git - gldbg.git/blobdiff - source/tmpalloc.c
Print the contents of arrays and references
[gldbg.git] / source / tmpalloc.c
diff --git a/source/tmpalloc.c b/source/tmpalloc.c
new file mode 100644 (file)
index 0000000..56d955e
--- /dev/null
@@ -0,0 +1,32 @@
+/* $Id$
+
+This file is part of gldbg
+Copyright © 2009  Mikko Rasa, Mikkosoft Productions
+Distributed under the GPL
+*/
+
+#include <stdlib.h>
+#include "tmpalloc.h"
+
+void *buffer = 0;
+unsigned buf_size = 8192;
+unsigned offset = 0;
+
+void *tmpalloc(unsigned size)
+{
+       void *ptr;
+       if(!buffer)
+               buffer = malloc(buf_size);
+       if(offset+size>buf_size)
+               offset = 0;
+       ptr = (char *)buffer+offset;
+       offset += size;
+       return ptr;
+}
+
+void tmpfree()
+{
+       free(buffer);
+       buffer = 0;
+       offset = 0;
+}