diff options
| author | Nic Gaffney <gaffney_nic@protonmail.com> | 2023-12-01 22:20:07 -0600 |
|---|---|---|
| committer | Nic Gaffney <gaffney_nic@protonmail.com> | 2023-12-01 22:20:07 -0600 |
| commit | d767828cee67bae17b811062949653234aa14b28 (patch) | |
| tree | 0a0306acc0fb9db19e6f7eff636d81c44209ee5d /std/stdmem.c | |
| parent | 52f12c6c2c946d8d3c0a7845d48e11ff8b8fb597 (diff) | |
| download | sloth-d767828cee67bae17b811062949653234aa14b28.tar.gz | |
shitty ptrs
Diffstat (limited to 'std/stdmem.c')
| -rw-r--r-- | std/stdmem.c | 20 |
1 files changed, 20 insertions, 0 deletions
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 <stdint.h> +#include <stdio.h> +#include <stdlib.h> +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]); +} |
