Runtime for checker...
[repair.git] / Repair / RepairCompiler / MCC / Runtime / instrument.cc
1 /* Defines interfaces for the applications and exports function calls that  
2    the applications should use instead of the standard ones. */
3
4 #include <stdlib.h>
5 #include <sys/time.h>
6 extern "C" {
7 #include "instrument.h"
8 }
9 #include <stdio.h>
10 #include "tmap.h"
11
12 typemap * memmap;
13
14 void *ourcalloc(size_t nmemb, size_t size) {
15   void *oc=calloc(nmemb,size);
16   memmap->allocate(oc,size*nmemb);
17   return oc;
18 }
19
20 void *ourmalloc(size_t size) {
21   void *oc=malloc(size);
22   memmap->allocate(oc,size);
23   return oc;
24 }
25
26 void ourfree(void *ptr) {
27   memmap->deallocate(ptr);
28   free(ptr);
29 }
30
31 void *ourrealloc(void *ptr, size_t size) {
32   void *orr=realloc(ptr,size);
33   if (size==0) {
34     memmap->deallocate(ptr);
35     return orr;
36   }
37   if (orr==NULL) {
38     return orr;
39   }
40   memmap->deallocate(ptr);
41   memmap->allocate(ptr,size);
42 }
43
44 void alloc(void *ptr,int size) {
45   memmap->allocate(ptr,size);
46 }
47
48 void dealloc(void *ptr) {
49   memmap->deallocate(ptr);
50 }