From d767828cee67bae17b811062949653234aa14b28 Mon Sep 17 00:00:00 2001 From: Nic Gaffney Date: Fri, 1 Dec 2023 22:20:07 -0600 Subject: shitty ptrs --- std/stdmem.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 std/stdmem.c (limited to 'std/stdmem.c') diff --git a/std/stdmem.c b/std/stdmem.c new file mode 100644 index 0000000..c3d0300 --- /dev/null +++ b/std/stdmem.c @@ -0,0 +1,20 @@ +#include +#include +#include +char *heap[100000]; +int heaploc = 0; + +int memalloc(int size) { + const int chunk = heaploc; + heap[heaploc++] = malloc(size); + printf("MEMALLOC: heap[%d]\n", chunk); + return chunk; +} +int drefi(int loc) { + printf("DREF: *heap[%d] = %d\n", loc, *heap[loc]); + return *heap[loc]; +} +void assignrefi(int loc, int num) { + *heap[loc] = num; + printf("ASSREF: *heap[%d] = %d\n", loc, *heap[loc]); +} -- cgit v1.2.3