diff options
author | rodri <rgl@antares-labs.eu> | 2020-06-29 18:24:47 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2020-06-29 18:24:47 +0000 |
commit | 5f823efa33ea598dabc3cb584363aa967bdf7b08 (patch) | |
tree | f2b4318f687a0fecd31d3adfc550234957e9edac /alloc.c | |
parent | 5d9dbc72e1c63b378023a283e53e43dc01a7b98c (diff) | |
download | 3dee-5f823efa33ea598dabc3cb584363aa967bdf7b08.tar.gz 3dee-5f823efa33ea598dabc3cb584363aa967bdf7b08.tar.bz2 3dee-5f823efa33ea598dabc3cb584363aa967bdf7b08.zip |
localize the draw channel. put the alloc code in its own module.
Diffstat (limited to 'alloc.c')
-rw-r--r-- | alloc.c | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -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; +} |