aboutsummaryrefslogtreecommitdiff
path: root/std/stdmem.c
blob: c3d030039a0104c92d69f176936f97900c00dd8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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]);
}