#ifndef RAII_H #define RAII_H #include "defs.h" unsigned long allocatedMem = 0; void *alloc(size_t size) { void *ptr = malloc(size); if (!ptr) { pter "Memory allocation failed" << nl; return NULL; } allocatedMem += 1; return ptr; } void dealloc(void *ptr) { if (ptr) free(ptr); allocatedMem -= 1; } bool assert_alloc() { return !allocatedMem; } #endif // RAII_H