X-Git-Url: http://plrg.eecs.uci.edu/git/?p=repair.git;a=blobdiff_plain;f=Repair%2FRepairCompiler%2FMCC%2FCRuntime%2Ftmap.c;h=bf03f04bada39ac855dcc5750b59d1d9e0b60708;hp=25c326d9068fcbfce731172d1d9170aff7a6e5ba;hb=9df765264fbe08940e8db8146ea8097733df06cf;hpb=5bdc1b8dceb971518a0e836661f01e783aa37d63 diff --git a/Repair/RepairCompiler/MCC/CRuntime/tmap.c b/Repair/RepairCompiler/MCC/CRuntime/tmap.c index 25c326d..bf03f04 100755 --- a/Repair/RepairCompiler/MCC/CRuntime/tmap.c +++ b/Repair/RepairCompiler/MCC/CRuntime/tmap.c @@ -4,8 +4,10 @@ #include "stack.h" #include +#ifndef COMMANDLINEFLAGS #define CHECKTYPE #define CHECKMEMORY +#endif struct typemap * allocatetypemap() { struct typemap *thisvar=(struct typemap *) malloc(sizeof(struct typemap)); @@ -80,6 +82,26 @@ bool typemapassertvalidmemory(struct typemap * thisvar, void* low, int s) { return typemapassertvalidmemoryB(thisvar, low,((char *)low)+toadd); } +bool typemapassertexactmemory(struct typemap * thisvar, void* low, int s) { + int toadd=sizeBytes(s); +#ifdef CHECKMEMORY + { + void * high=((char *)low)+toadd; + struct pair allocp=rbfind(low,high,thisvar->alloctree); + if (allocp.low == NULL) { + return false; + } else if ((allocp.low != low) || (allocp.high != high)) { + /* make sure this block exactly lines up */ + return false; + } else { + return true; + } + } +#else + return true; +#endif +} + bool typemapassertvalidmemoryB(struct typemap * thisvar, void* low, void* high) { #ifdef CHECKMEMORY return typemapcheckmemory(thisvar, low, high); @@ -161,6 +183,17 @@ bool typemapcheckmemory(struct typemap *thisvar, void* low, void* high) { } } +void * typemapgetendofblock(struct typemap *thisvar, void* low) { + struct pair allocp=rbfind(low,((char*)low)+1,thisvar->alloctree); + if (allocp.low == NULL) { + return NULL; + } else if ((allocp.low > low)||(allocp.high <= allocp.low)) { /* make sure this block is used */ + return NULL; + } else { + return (void *)allocp.high; + } +} + bool typemapchecktype(struct typemap *thisvar, bool doaction,void *ptr, int structure) { int ssize=sizeBytes(structure);