diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-04-11 05:03:49 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-04-11 05:03:49 +0200 |
commit | 1b8a56941708e6fe884f4649f718fae7c543c045 (patch) | |
tree | 3d7be0a7e43b01aba6dd986bff06bcc3947a6d78 /sys/src/cmd/5l/compat.c | |
parent | 9d46360c9d83fa95f42f1eebbad49ecd9281fb0d (diff) |
cc, ?[acl]: fix gethunk() and move common memory allocator code to cc/compat
for gethunk() to work, all allocators have to use it,
including allocations done by libc thru malloc(),
so the fake allocation functions are mandatory for
everyone.
to avoid duplication the code is moved to cc/compat
and prototypes provided in new cc/compat.h header.
Diffstat (limited to 'sys/src/cmd/5l/compat.c')
-rw-r--r-- | sys/src/cmd/5l/compat.c | 56 |
1 files changed, 1 insertions, 55 deletions
diff --git a/sys/src/cmd/5l/compat.c b/sys/src/cmd/5l/compat.c index 1d9f89e43..54ac0283e 100644 --- a/sys/src/cmd/5l/compat.c +++ b/sys/src/cmd/5l/compat.c @@ -1,56 +1,2 @@ #include "l.h" - -/* - * fake malloc - */ -void* -malloc(ulong n) -{ - void *p; - - while(n & 7) - n++; - while(nhunk < n) - gethunk(); - p = hunk; - nhunk -= n; - hunk += n; - return p; -} - -void -free(void *p) -{ - USED(p); -} - -void* -calloc(ulong m, ulong n) -{ - void *p; - - n *= m; - p = malloc(n); - memset(p, 0, n); - return p; -} - -void* -realloc(void *p, ulong n) -{ - fprint(2, "realloc(0x%p %ld) called\n", p, n); - abort(); - return 0; -} - -void* -mysbrk(ulong size) -{ - return sbrk(size); -} - -void -setmalloctag(void *v, uintptr pc) -{ - USED(v, pc); -} +#include "../cc/compat" |