|
#ifndef R_MALLOC
|
|
#define R_MALLOC
|
|
#include <malloc.h>
|
|
|
|
long long int r_malloc_alloc_count = 0;
|
|
long long int r_malloc_alloc_total = 0;
|
|
|
|
void *r_malloc(size_t size) {
|
|
r_malloc_alloc_count++;
|
|
r_malloc_alloc_total++;
|
|
|
|
return malloc(size);
|
|
}
|
|
|
|
void r_free(void *ptr) {
|
|
r_malloc_alloc_count--;
|
|
|
|
free(ptr);
|
|
}
|
|
|
|
void r_malloc_stats() {
|
|
fprintf(stderr, "r_malloc_alloc_count: %lld\n", r_malloc_alloc_count);
|
|
fprintf(stderr, "r_malloc_alloc_total: %lld\n", r_malloc_alloc_total);
|
|
fprintf(stderr, "r_malloc_freed_total: %lld\n",
|
|
r_malloc_alloc_total - r_malloc_alloc_count);
|
|
}
|
|
|
|
#define malloc(x) r_malloc(x)
|
|
#define free(x) r_free(x)
|
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|