ref: cd46c2b490f73e5cd366b6230cba1eac0b4d01e2
parent: f3519cb0fa6379bd0bb074bcdb82bff9c2b8e05d
author: Yaroslav Kolomiiets <yarikos@gmail.com>
date: Fri Aug 5 11:42:05 EDT 2016
add alloc.c
--- /dev/null
+++ b/alloc.c
@@ -1,0 +1,29 @@
+#include <u.h>
+#include <libc.h>
+#include <draw.h>
+#include "dat.h"
+#include "fns.h"
+
+void*
+emalloc(ulong n)
+{
+ void *b;
+
+ b = mallocz(n, 1);
+ if(b == nil)
+ sysfatal("out of memory allocating %lud: %r", n);
+ setmalloctag(b, getcallerpc(&n));
+ return b;
+}
+
+void*
+erealloc(void *a, ulong n)
+{
+ void *b;
+
+ b = realloc(a, n);
+ if(b == nil)
+ sysfatal("out of memory re-allocating %lud: %r", n);
+ setrealloctag(b, getcallerpc(&a));
+ return b;
+}