diff options
author | rodri <rgl@antares-labs.eu> | 2021-03-06 17:11:47 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2021-03-06 17:11:47 +0000 |
commit | 5ecc14e07c5dcc40e418f450f0c34dceb7f7e326 (patch) | |
tree | d916d6934cc119c192cae31d6b791d8b94e14421 /alloc.c | |
download | gamephysics-5ecc14e07c5dcc40e418f450f0c34dceb7f7e326.tar.gz gamephysics-5ecc14e07c5dcc40e418f450f0c34dceb7f7e326.tar.bz2 gamephysics-5ecc14e07c5dcc40e418f450f0c34dceb7f7e326.zip |
implemented three integrators and a simple time stepping model.
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; +} |