aboutsummaryrefslogtreecommitdiff
path: root/alloc.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-07-23 22:52:31 +0000
committerrodri <rgl@antares-labs.eu>2023-07-23 22:52:31 +0000
commit2e99eaaea1aa6776eda10f5ec8bd90adcfe8424a (patch)
treefe2602798fbafacef77d0636c7ef5f717a12bbed /alloc.c
downloadcatphone-2e99eaaea1aa6776eda10f5ec8bd90adcfe8424a.tar.gz
catphone-2e99eaaea1aa6776eda10f5ec8bd90adcfe8424a.tar.bz2
catphone-2e99eaaea1aa6776eda10f5ec8bd90adcfe8424a.zip
layed out initial structures. began work on registration procedure.
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..ede5d64
--- /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;
+}