aboutsummaryrefslogtreecommitdiff
path: root/alloc.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2020-06-12 21:57:48 +0000
committerrodri <rgl@antares-labs.eu>2020-06-12 21:57:48 +0000
commit0b0726f3a990ee241fd93b5c3f53631bfbb4c455 (patch)
tree72942206518cf8f2da7ed1b744077d4a5343fa29 /alloc.c
parent60bbfc0e2353b834409ecefd10ae3985f5cbf111 (diff)
downloadpuppeteer-0b0726f3a990ee241fd93b5c3f53631bfbb4c455.tar.gz
puppeteer-0b0726f3a990ee241fd93b5c3f53631bfbb4c455.tar.bz2
puppeteer-0b0726f3a990ee241fd93b5c3f53631bfbb4c455.zip
layout done. implemented some error-checking wrappers and started work on layers.
Diffstat (limited to 'alloc.c')
-rw-r--r--alloc.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/alloc.c b/alloc.c
new file mode 100644
index 0000000..2589e89
--- /dev/null
+++ b/alloc.c
@@ -0,0 +1,44 @@
+#include <u.h>
+#include <libc.h>
+#include <draw.h>
+
+void*
+emalloc(ulong n)
+{
+ void *p;
+
+ p = malloc(n);
+ if(p == nil)
+ sysfatal("malloc: %r");
+ setmalloctag(p, getcallerpc(&n));
+ return p;
+}
+
+void*
+erealloc(void *p, ulong n)
+{
+ void *np;
+
+ np = realloc(p, n);
+ if(np == nil){
+ if(n == 0)
+ return nil;
+ sysfatal("realloc: %r");
+ }
+ if(p == nil)
+ setmalloctag(np, getcallerpc(&p));
+ else
+ setrealloctag(np, getcallerpc(&p));
+ return np;
+}
+
+Image*
+eallocimage(Display *d, Rectangle r, ulong chan, int repl, ulong col)
+{
+ Image *i;
+
+ i = allocimage(d, r, chan, repl, col);
+ if(i == nil)
+ sysfatal("allocimage: %r");
+ return i;
+}