vile / scheme / testdata / goops_heap / hooks.c
16 lines · 16 sloc · 560 bytes · 76646891b77a3d5c6af4a1e42b122cd61dc1654b
Raw
1#include "hooks.h"
2static int armed;
3static uint64_t allocations, releases, bytes;
4void vheap_alloc(void *pointer, uint64_t size) {
5 (void)pointer;
6 if (armed) { allocations++; bytes += size; }
7}
8void vheap_free(void *pointer) {
9 (void)pointer;
10 if (armed) releases++;
11}
12void goops_heap_arm(void) { allocations = releases = bytes = 0; armed = 1; }
13void goops_heap_disarm(void) { armed = 0; }
14uint64_t goops_heap_allocations(void) { return allocations; }
15uint64_t goops_heap_releases(void) { return releases; }
16uint64_t goops_heap_bytes(void) { return bytes; }
17