1 /* Defines interfaces for the applications and exports function calls that
2 the applications should use instead of the standard ones. */
7 #include "instrument.h"
13 struct typemap * memmap;
15 void *ourcalloc(size_t nmemb, size_t size) {
16 void *oc=calloc(nmemb,size);
17 typemapallocate(memmap, oc,size*nmemb);
21 void *ourmalloc(size_t size) {
22 void *oc=malloc(size);
23 typemapallocate(memmap, oc,size);
27 void ourfree(void *ptr) {
29 typemapdeallocate(memmap, ptr);
34 void *ourrealloc(void *ptr, size_t size) {
35 void *orr=realloc(ptr,size);
37 typemapdeallocate(memmap, ptr);
43 typemapdeallocate(memmap, ptr);
44 typemapallocate(memmap, orr,size);
48 char *ourstrdup(const char *ptr) {
49 char *new_ptr=strdup(ptr);
50 int length=strlen(ptr)+1;
51 typemapallocate(memmap,new_ptr,length);
56 void alloc(void *ptr,int size) {
57 typemapallocate(memmap, ptr,size);
60 void dealloc(void *ptr) {
61 typemapdeallocate(memmap, ptr);
64 void initializemmap() {
65 memmap=allocatetypemap();
72 bool assertvalidtype(int ptr, int structure) {
73 return typemapasserttype(memmap, (void *)ptr, structure);
75 bool assertvalidmemory(int ptr, int structure) {
76 return typemapassertvalidmemory(memmap, (void *)ptr, structure);
79 bool assertexactmemory(int ptr, int structure) {
80 return typemapassertexactmemory(memmap, (void *)ptr, structure);
83 void * getendofblock(int ptr) {
84 return typemapgetendofblock(memmap, (void *)ptr);
87 void initializestack(void *high) {
88 initializetypemapstack(memmap, high);