/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/KalFitAlg/KalFitAlg-00-07-55-p03/KalFitAlg/KalFitMemLeak.h File Reference

#include <stdlib.h>

Go to the source code of this file.

Defines

#define MW_ARI_NULLREAD   0x10
#define MW_ARI_ABORT   0x04
#define MW_ARI_RETRY   0x02
#define MW_ARI_IGNORE   0x01
#define MW_VAL_NEW   0xFE
#define MW_VAL_DEL   0xFD
#define MW_VAL_NML   0xFC
#define MW_VAL_GRB   0xFB
#define MW_TEST_ALL   0xFFFF
#define MW_TEST_CHAIN   0x0001
#define MW_TEST_ALLOC   0x0002
#define MW_TEST_NML   0x0004
#define MW_NML_NONE   0
#define MW_NML_FREE   1
#define MW_NML_ALL   2
#define MW_NML_DEFAULT   0
#define MW_STAT_GLOBAL   0
#define MW_STAT_MODULE   1
#define MW_STAT_LINE   2
#define MW_STAT_DEFAULT   0
#define MW_TRACE_BUFFER   2048
#define MW_FREE_LIST   64
#define mwASSERT(exp)
#define ASSERT   mwASSERT
#define mwVERIFY(exp)   exp
#define VERIFY   mwVERIFY
#define mwTRACE   /*lint -save -e506 */ 1?(void)0:mwDummyTraceFunction
#define TRACE   mwTRACE
#define mwDoFlush(n)
#define mwPuts(s)
#define mwInit()
#define mwGrab(n)
#define mwDrop(n)
#define mwLimit(n)
#define mwTest(f, l)
#define mwSetOutFunc(f)
#define mwSetAriFunc(f)
#define mwDefaultAri()
#define mwNomansland()
#define mwStatistics(f)
#define mwMark(p, t, f, n)   (p)
#define mwUnmark(p, f, n)   (p)
#define mwMalloc(n, f, l)   malloc(n)
#define mwStrdup(p, f, l)   strdup(p)
#define mwRealloc(p, n, f, l)   realloc(p,n)
#define mwCalloc(n, m, f, l)   calloc(n,m)
#define mwFree(p)   free(p)
#define mwMalloc_(n)   malloc(n)
#define mwRealloc_(p, n)   realloc(p,n)
#define mwCalloc_(n, m)   calloc(n,m)
#define mwFree_(p)   free(p)
#define mwAssert(e, es, f, l)
#define mwVerify(e, es, f, l)   (e)
#define mwTrace   mwDummyTrace
#define mwTestBuffer(f, l, b)   (0)
#define CHECK()
#define CHECK_THIS(n)
#define CHECK_BUFFER(b)
#define MARK(p)   (p)
#define UNMARK(p)   (p)

Functions

void mwTerm (void)
void mwAbort (void)
void mwFlushNow (void)
void mwDoFlush (int onoff)
void mwLimit (long bytes)
unsigned mwGrab (unsigned kilobytes)
unsigned mwDrop (unsigned kilobytes)
void mwNoMansLand (int mw_nml_level)
void mwStatistics (int level)
void mwFreeBufferInfo (int onoff)
void mwAutoCheck (int onoff)
void mwCalcCheck (void)
void mwDumpCheck (void)
void * mwMark (void *p, const char *description, const char *file, unsigned line)
void * mwUnmark (void *p, const char *file, unsigned line)
int mwIsReadAddr (const void *p, unsigned len)
int mwIsSafeAddr (void *p, unsigned len)
int mwTest (const char *file, int line, int mw_test_flags)
int mwTestBuffer (const char *file, int line, void *p)
int mwAssert (int, const char *, const char *, int)
int mwVerify (int, const char *, const char *, int)
void mwTrace (const char *format_string,...)
void mwPuts (const char *text)
void mwSetOutFunc (void(*func)(int))
void mwSetAriFunc (int(*func)(const char *))
void mwSetAriAction (int mw_ari_value)
int mwAriHandler (const char *cause)
void mwBreakOut (const char *cause)
void * mwMalloc (size_t, const char *, int)
void * mwMalloc_ (size_t)
void * mwRealloc (void *, size_t, const char *, int)
void * mwRealloc_ (void *, size_t)
void * mwCalloc (size_t, size_t, const char *, int)
void * mwCalloc_ (size_t, size_t)
void mwFree (void *, const char *, int)
void mwFree_ (void *)
char * mwStrdup (const char *, const char *, int)
void mwDummyTraceFunction (const char *,...)

Variables

const unsigned long mwCounter


Define Documentation

#define ASSERT   mwASSERT

Definition at line 594 of file KalFitMemLeak.h.

 
#define CHECK (  ) 

Definition at line 643 of file KalFitMemLeak.h.

#define CHECK_BUFFER (  ) 

Definition at line 645 of file KalFitMemLeak.h.

#define CHECK_THIS (  ) 

Definition at line 644 of file KalFitMemLeak.h.

#define MARK (  )     (p)

Definition at line 646 of file KalFitMemLeak.h.

#define MW_ARI_ABORT   0x04

Definition at line 349 of file KalFitMemLeak.h.

Referenced by mwARI().

#define MW_ARI_IGNORE   0x01

Definition at line 351 of file KalFitMemLeak.h.

Referenced by mwARI(), mwAssert(), and mwVerify().

#define MW_ARI_NULLREAD   0x10

Definition at line 348 of file KalFitMemLeak.h.

Referenced by mwAssert(), and mwVerify().

#define MW_ARI_RETRY   0x02

Definition at line 350 of file KalFitMemLeak.h.

Referenced by mwARI(), and mwAssert().

#define MW_FREE_LIST   64

Definition at line 379 of file KalFitMemLeak.h.

Referenced by mwFree(), and mwRealloc().

#define MW_NML_ALL   2

Definition at line 365 of file KalFitMemLeak.h.

Referenced by mwNoMansLand().

#define MW_NML_DEFAULT   0

Definition at line 366 of file KalFitMemLeak.h.

#define MW_NML_FREE   1

Definition at line 364 of file KalFitMemLeak.h.

Referenced by mwNoMansLand().

#define MW_NML_NONE   0

Definition at line 363 of file KalFitMemLeak.h.

Referenced by mwNoMansLand().

#define MW_STAT_DEFAULT   0

Definition at line 371 of file KalFitMemLeak.h.

#define MW_STAT_GLOBAL   0

Definition at line 368 of file KalFitMemLeak.h.

#define MW_STAT_LINE   2

Definition at line 370 of file KalFitMemLeak.h.

#define MW_STAT_MODULE   1

Definition at line 369 of file KalFitMemLeak.h.

#define MW_TEST_ALL   0xFFFF

Definition at line 358 of file KalFitMemLeak.h.

Referenced by mwAutoCheck().

#define MW_TEST_ALLOC   0x0002

Definition at line 360 of file KalFitMemLeak.h.

Referenced by mwTestNow().

#define MW_TEST_CHAIN   0x0001

Definition at line 359 of file KalFitMemLeak.h.

Referenced by mwTestNow().

#define MW_TEST_NML   0x0004

Definition at line 361 of file KalFitMemLeak.h.

Referenced by mwTestNow().

#define MW_TRACE_BUFFER   2048

Definition at line 378 of file KalFitMemLeak.h.

Referenced by mwAssert(), mwTrace(), mwVerify(), and mwWrite().

#define MW_VAL_DEL   0xFD

Definition at line 354 of file KalFitMemLeak.h.

Referenced by mwFree().

#define MW_VAL_GRB   0xFB

Definition at line 356 of file KalFitMemLeak.h.

Referenced by mwDrop(), mwDropAll(), mwFreeUp(), mwGrab(), and mwGrabType().

#define MW_VAL_NEW   0xFE

Definition at line 353 of file KalFitMemLeak.h.

Referenced by mwMalloc().

#define MW_VAL_NML   0xFC

Definition at line 355 of file KalFitMemLeak.h.

Referenced by mwAbort(), mwDropAll(), mwFree(), mwFreeUp(), mwGrabType(), mwNoMansLand(), mwRealloc(), and mwTestNow().

#define mwAssert ( e,
es,
f,
 ) 

Definition at line 639 of file KalFitMemLeak.h.

#define mwASSERT ( exp   ) 

Definition at line 591 of file KalFitMemLeak.h.

#define mwCalloc ( n,
m,
f,
 )     calloc(n,m)

Definition at line 633 of file KalFitMemLeak.h.

#define mwCalloc_ ( n,
 )     calloc(n,m)

Definition at line 637 of file KalFitMemLeak.h.

 
#define mwDefaultAri (  ) 

Definition at line 625 of file KalFitMemLeak.h.

#define mwDoFlush (  ) 

Definition at line 616 of file KalFitMemLeak.h.

#define mwDrop (  ) 

Definition at line 620 of file KalFitMemLeak.h.

#define mwFree (  )     free(p)

Definition at line 634 of file KalFitMemLeak.h.

Referenced by mwRealloc().

#define mwFree_ (  )     free(p)

Definition at line 638 of file KalFitMemLeak.h.

Referenced by mwFree().

#define mwGrab (  ) 

Definition at line 619 of file KalFitMemLeak.h.

void mwInit ( void   ) 

Definition at line 618 of file KalFitMemLeak.h.

Referenced by mwAutoInit().

#define mwLimit (  ) 

Definition at line 621 of file KalFitMemLeak.h.

#define mwMalloc ( n,
f,
 )     malloc(n)

Definition at line 630 of file KalFitMemLeak.h.

Referenced by mwCalloc(), mwRealloc(), and mwStrdup().

#define mwMalloc_ (  )     malloc(n)

Definition at line 635 of file KalFitMemLeak.h.

#define mwMark ( p,
t,
f,
 )     (p)

Definition at line 628 of file KalFitMemLeak.h.

 
#define mwNomansland (  ) 

Definition at line 626 of file KalFitMemLeak.h.

#define mwPuts ( s   ) 

Definition at line 617 of file KalFitMemLeak.h.

#define mwRealloc ( p,
n,
f,
 )     realloc(p,n)

Definition at line 632 of file KalFitMemLeak.h.

#define mwRealloc_ ( p,
 )     realloc(p,n)

Definition at line 636 of file KalFitMemLeak.h.

#define mwSetAriFunc (  ) 

Definition at line 624 of file KalFitMemLeak.h.

#define mwSetOutFunc (  ) 

Definition at line 623 of file KalFitMemLeak.h.

#define mwStatistics (  ) 

Definition at line 627 of file KalFitMemLeak.h.

#define mwStrdup ( p,
f,
 )     strdup(p)

Definition at line 631 of file KalFitMemLeak.h.

#define mwTest ( f,
 ) 

Definition at line 622 of file KalFitMemLeak.h.

#define mwTestBuffer ( f,
l,
 )     (0)

Definition at line 642 of file KalFitMemLeak.h.

#define mwTrace   mwDummyTrace

Definition at line 641 of file KalFitMemLeak.h.

Referenced by mwTrace().

#define mwTRACE   /*lint -save -e506 */ 1?(void)0:mwDummyTraceFunction

Definition at line 606 of file KalFitMemLeak.h.

#define mwUnmark ( p,
f,
 )     (p)

Definition at line 629 of file KalFitMemLeak.h.

#define mwVerify ( e,
es,
f,
 )     (e)

Definition at line 640 of file KalFitMemLeak.h.

#define mwVERIFY ( exp   )     exp

Definition at line 598 of file KalFitMemLeak.h.

#define TRACE   mwTRACE

Definition at line 610 of file KalFitMemLeak.h.

#define UNMARK (  )     (p)

Definition at line 647 of file KalFitMemLeak.h.

#define VERIFY   mwVERIFY

Definition at line 601 of file KalFitMemLeak.h.


Function Documentation

void mwAbort ( void   ) 

Definition at line 517 of file KalFitMemLeak.c.

References mwData_::count, mwData_::file, mwData_::flag, FLUSH, mwMarker_::host, genRecEmupikp::i, ganga-rec::j, mwData_::line, mw, MW_MUTEX_TERM, MW_NML, MW_VAL_NML, mwCheckOF(), mwDataSize, mwDropAll(), mwErrors, mwFirstMark, mwFlushW(), mwHead, mwInited, mwIsOwned(), mwLogFile(), mwNmlCurAlloc, mwNmlNumAlloc, mwOverflowZoneSize, mwStatReport(), mwSTDERR, mwTail, mwTestMem(), mwUnlink(), mwWrite(), mwMarker_::next, mwData_::size, and mwMarker_::text.

Referenced by mwInit(), and mwTerm().

00517                      {
00518     mwData *mw;
00519     mwMarker *mrk;
00520     char *data;
00521     time_t tid;
00522     int c, i, j;
00523         int errors;
00524 
00525     tid = time( NULL );
00526     mwWrite( "\nStopped at %s\n", ctime( &tid) );
00527 
00528     if( !mwInited )
00529         mwWrite( "internal: mwAbort(): MEMWATCH not initialized!\n" );
00530 
00531     /* release the grab list */
00532     mwDropAll();
00533 
00534     /* report mwMarked items */
00535     while( mwFirstMark ) {
00536         mrk = mwFirstMark->next;
00537         mwWrite( "mark: %p: %s\n", mwFirstMark->host, mwFirstMark->text );
00538         free( mwFirstMark->text );
00539         free( mwFirstMark );
00540         mwFirstMark = mrk;
00541         mwErrors ++;
00542         }
00543 
00544     /* release all still allocated memory */
00545         errors = 0;
00546     while( mwHead != NULL && errors < 3 ) {
00547                 if( !mwIsOwned(mwHead, __FILE__, __LINE__ ) ) {
00548                         if( errors < 3 )
00549                         {
00550                                 errors ++;
00551                                 mwWrite( "internal: NML/unfreed scan restarting\n" );
00552                                 FLUSH();
00553                                 mwHead = mwHead;
00554                                 continue;
00555                         }
00556                         mwWrite( "internal: NML/unfreed scan aborted, heap too damaged\n" );
00557                         FLUSH();
00558                         break;
00559                         }
00560         mwFlushW(0);
00561         if( !(mwHead->flag & MW_NML) ) {
00562             mwErrors++;
00563             data = ((char*)mwHead)+mwDataSize;
00564             mwWrite( "unfreed: <%ld> %s(%d), %ld bytes at %p ",
00565                 mwHead->count, mwHead->file, mwHead->line, (long)mwHead->size, data+mwOverflowZoneSize );
00566             if( mwCheckOF( data ) ) {
00567                 mwWrite( "[underflowed] ");
00568                 FLUSH();
00569                 }
00570             if( mwCheckOF( (data+mwOverflowZoneSize+mwHead->size) ) ) {
00571                 mwWrite( "[overflowed] ");
00572                 FLUSH();
00573                 }
00574             mwWrite( " \t{" );
00575             j = 16; if( mwHead->size < 16 ) j = (int) mwHead->size;
00576             for( i=0;i<16;i++ ) {
00577                 if( i<j ) mwWrite( "%02X ",
00578                     (unsigned char) *(data+mwOverflowZoneSize+i) );
00579                 else mwWrite( ".. " );
00580                 }
00581             for( i=0;i<j;i++ ) {
00582                 c = *(data+mwOverflowZoneSize+i);
00583                 if( c < 32 || c > 126 ) c = '.';
00584                 mwWrite( "%c", c );
00585                 }
00586             mwWrite( "}\n" );
00587                         mw = mwHead;
00588                         mwUnlink( mw, __FILE__, __LINE__ );
00589             free( mw );
00590             }
00591         else {
00592             data = ((char*)mwHead) + mwDataSize + mwOverflowZoneSize;
00593             if( mwTestMem( data, mwHead->size, MW_VAL_NML ) ) {
00594                 mwErrors++;
00595                 mwWrite( "wild pointer: <%ld> NoMansLand %p alloc'd at %s(%d)\n",
00596                     mwHead->count, data + mwOverflowZoneSize, mwHead->file, mwHead->line );
00597                 FLUSH();
00598                 }
00599                         mwNmlNumAlloc --;
00600                         mwNmlCurAlloc -= mwHead->size;
00601                         mw = mwHead;
00602                         mwUnlink( mw, __FILE__, __LINE__ );
00603             free( mw );
00604             }
00605         }
00606 
00607         if( mwNmlNumAlloc ) mwWrite("internal: NoMansLand block counter %ld, not zero\n", mwNmlNumAlloc );
00608         if( mwNmlCurAlloc ) mwWrite("internal: NoMansLand byte counter %ld, not zero\n", mwNmlCurAlloc );
00609 
00610     /* report statistics */
00611     mwStatReport();
00612     FLUSH();
00613 
00614     mwInited = 0;
00615     mwHead = mwTail = NULL;
00616     if( mwErrors )
00617         fprintf(mwSTDERR,"MEMWATCH detected %ld anomalies\n",mwErrors);
00618     mwLogFile( NULL );
00619     mwErrors = 0;
00620 
00621     MW_MUTEX_TERM();
00622 
00623     }

int mwAriHandler ( const char *  cause  ) 

Definition at line 848 of file KalFitMemLeak.c.

References mwARI(), and mwAutoInit().

00848                                      {
00849     mwAutoInit();
00850     return mwARI( estr );
00851     }

int mwAssert ( int  ,
const char *  ,
const char *  ,
int   
)

Definition at line 1228 of file KalFitMemLeak.c.

References FLUSH, genRecEmupikp::i, MW_ARI_IGNORE, MW_ARI_NULLREAD, MW_ARI_RETRY, MW_MUTEX_LOCK, MW_MUTEX_UNLOCK, MW_TRACE_BUFFER, mwAriAction, mwAriFunction, mwAutoInit(), mwCounter, mwDummy(), mwIncErr(), mwSTDERR, mwTestNow(), mwWrite(), and TESTS.

01228                                                                   {
01229     int i;
01230     char buffer[MW_TRACE_BUFFER+8];
01231     if( exp ) {
01232         return 0;
01233         }
01234     mwAutoInit();
01235         MW_MUTEX_LOCK();
01236     TESTS(fn,ln);
01237     mwIncErr();
01238     mwCounter++;
01239     mwWrite( "assert trap: <%ld> %s(%d), %s\n", mwCounter, fn, ln, exps );
01240     if( mwAriFunction != NULL ) {
01241         sprintf( buffer, "MEMWATCH: assert trap: %s(%d), %s", fn, ln, exps );
01242         i = (*mwAriFunction)(buffer);
01243                 switch( i ) {
01244                         case MW_ARI_IGNORE:
01245                         mwWrite( "assert trap: <%ld> IGNORED - execution continues\n", mwCounter );
01246                                 MW_MUTEX_UNLOCK();
01247                 return 0;
01248                         case MW_ARI_RETRY:
01249                 mwWrite( "assert trap: <%ld> RETRY - executing again\n", mwCounter );
01250                                 MW_MUTEX_UNLOCK();
01251                 return 1;
01252                         }
01253         }
01254     else {
01255         if( mwAriAction & MW_ARI_IGNORE ) {
01256             mwWrite( "assert trap: <%ld> AUTO IGNORED - execution continues\n", mwCounter );
01257                         MW_MUTEX_UNLOCK();
01258             return 0;
01259             }
01260         fprintf(mwSTDERR,"\nMEMWATCH: assert trap: %s(%d), %s\n", fn, ln, exps );
01261         }
01262 
01263     FLUSH();
01264     (void) mwTestNow( fn, ln, 1 );
01265     FLUSH();
01266 
01267         if( mwAriAction & MW_ARI_NULLREAD ) {
01268                 /* This is made in an attempt to kick in */
01269                 /* any debuggers or OS stack traces */
01270             FLUSH();
01271                 /*lint -save -e413 */
01272                 i = *((int*)NULL);
01273                 mwDummy( (char)i );
01274                 /*lint -restore */
01275                 }
01276 
01277         MW_MUTEX_UNLOCK();
01278     exit(255);
01279     /* NOT REACHED - the return statement is in to keep */
01280     /* stupid compilers from squeaking about differing return modes. */
01281     /* Smart compilers instead say 'code unreachable...' */
01282     /*lint -save -e527 */
01283     return 0;
01284     /*lint -restore */
01285     }

void mwAutoCheck ( int  onoff  ) 

Definition at line 649 of file KalFitMemLeak.c.

References MW_TEST_ALL, mwAutoInit(), mwTestAlways, and mwTestFlags.

00649                               {
00650     mwAutoInit();
00651     mwTestAlways = onoff;
00652     if( onoff ) mwTestFlags = MW_TEST_ALL;
00653     }

void mwBreakOut ( const char *  cause  ) 

Definition at line 709 of file KalFitMemLeak.c.

References mwSTDERR, and mwWrite().

Referenced by mwARI().

00709                                      {
00710     fprintf(mwSTDERR, "breakout: %s\n", cause);
00711     mwWrite("breakout: %s\n", cause );
00712     return;
00713     }

void mwCalcCheck ( void   ) 

void* mwCalloc ( size_t  ,
size_t  ,
const char *  ,
int   
)

Definition at line 1154 of file KalFitMemLeak.c.

References mwMalloc, and delete_small_size::size.

01154                                                                  {
01155     void *p;
01156     size_t size = a * b;
01157     p = mwMalloc( size, file, line );
01158     if( p == NULL ) return NULL;
01159     memset( p, 0, size );
01160     return p;
01161     }

void* mwCalloc_ ( size_t  ,
size_t   
)

Definition at line 1184 of file KalFitMemLeak.c.

References MW_MUTEX_LOCK, MW_MUTEX_UNLOCK, and TESTS.

01184                                       {
01185         MW_MUTEX_LOCK();
01186     TESTS(NULL,0);
01187         MW_MUTEX_UNLOCK();
01188     return calloc( a, b );
01189     }

void mwDoFlush ( int  onoff  ) 

Definition at line 1196 of file KalFitMemLeak.c.

References mwFlushW(), and mwLogR().

01196                             {
01197     mwFlushW( onoff<1?0:onoff );
01198     if( onoff ) if( mwLogR() ) fflush( mwLogR() );
01199     return;
01200     }

unsigned mwDrop ( unsigned  kilobytes  ) 

Definition at line 1377 of file KalFitMemLeak.c.

References MW_VAL_GRB, mwDrop_(), and TESTS.

01377                                {
01378     TESTS(NULL,0);
01379     return mwDrop_( kb, MW_VAL_GRB, 0 );
01380     }

void mwDummyTraceFunction ( const char *  ,
  ... 
)

void mwDumpCheck ( void   ) 

void mwFlushNow ( void   ) 

Definition at line 1191 of file KalFitMemLeak.c.

References mwLogR().

01191                         {
01192     if( mwLogR() ) fflush( mwLogR() );
01193     return;
01194     }

void mwFree ( void *  ,
const char *  ,
int   
)

Definition at line 1051 of file KalFitMemLeak.c.

References FLUSH, genRecEmupikp::i, mw, MW_FREE_LIST, MW_MUTEX_LOCK, MW_MUTEX_UNLOCK, MW_NML, MW_VAL_DEL, MW_VAL_NML, mwAutoInit(), mwBUFFER_TO_MW, mwCounter, mwDataSize, mwFBI, mwFree_, mwIncErr(), mwIsOwned(), mwLastFree, mwLFcur, mwLFfile, mwLFline, mwNML, mwNmlCurAlloc, mwNmlNumAlloc, mwNumCurAlloc, mwOverflowZoneSize, mwROUNDALLOC, mwStatCurAlloc, mwStatFree(), mwStatLevel, mwTestBuf(), mwUnlink(), mwWrite(), and TESTS.

01051                                                    {
01052     int i;
01053     mwData* mw;
01054     char buffer[ sizeof(mwData) + (mwROUNDALLOC*3) + 64 ];
01055 
01056     /* this code is in support of C++ delete */
01057     if( file == NULL ) {
01058         mwFree_( p );
01059                 MW_MUTEX_UNLOCK();
01060         return;
01061         }
01062 
01063     mwAutoInit();
01064 
01065         MW_MUTEX_LOCK();
01066     TESTS(file,line);
01067     mwCounter ++;
01068 
01069     /* on NULL free, write a warning and return */
01070     if( p == NULL ) {
01071         mwWrite( "NULL free: <%ld> %s(%d), NULL pointer free'd\n",
01072             mwCounter, file, line );
01073         FLUSH();
01074                 MW_MUTEX_UNLOCK();
01075         return;
01076         }
01077 
01078     /* do the quick ownership test */
01079     mw = (mwData*) mwBUFFER_TO_MW( p );
01080 
01081     if( mwIsOwned( mw, file, line ) ) {
01082         (void) mwTestBuf( mw, file, line );
01083 
01084                 /* if the buffer is an NML, treat this as a double-free */
01085                 if( mw->flag & MW_NML )
01086                 {
01087                         if( *(((unsigned char*)mw)+mwDataSize+mwOverflowZoneSize) != MW_VAL_NML )
01088                         {
01089                                 mwWrite( "internal: <%ld> %s(%d), no-mans-land MW-%p is corrupted\n",
01090                                         mwCounter, file, line, mw );
01091                         }
01092                         goto check_dbl_free;
01093                 }
01094 
01095         /* update the statistics */
01096         mwNumCurAlloc --;
01097         mwStatCurAlloc -= (long) mw->size;
01098         if( mwStatLevel ) mwStatFree( mw->size, mw->file, mw->line );
01099 
01100         /* we should either free the allocation or keep it as NML */
01101         if( mwNML ) {
01102             mw->flag |= MW_NML;
01103                         mwNmlNumAlloc ++;
01104                         mwNmlCurAlloc += (long) mw->size;
01105             memset( ((char*)mw)+mwDataSize+mwOverflowZoneSize, MW_VAL_NML, mw->size );
01106             }
01107         else {
01108             /* unlink the allocation, and enter the post-free data */
01109             mwUnlink( mw, file, line );
01110             memset( mw, MW_VAL_DEL,
01111                 mw->size + mwDataSize+mwOverflowZoneSize+mwOverflowZoneSize );
01112             if( mwFBI ) {
01113                 memset( mw, '.', mwDataSize + mwOverflowZoneSize );
01114                 sprintf( buffer, "FBI<%ld>%s(%d)", mwCounter, file, line );
01115                 strncpy( (char*)(void*)mw, buffer, mwDataSize + mwOverflowZoneSize );
01116                 }
01117             free( mw );
01118             }
01119 
01120         /* add the pointer to the last-free track */
01121         mwLFfile[ mwLFcur ] = file;
01122         mwLFline[ mwLFcur ] = line;
01123         mwLastFree[ mwLFcur++ ] = p;
01124         if( mwLFcur == MW_FREE_LIST ) mwLFcur = 0;
01125 
01126                 MW_MUTEX_UNLOCK();
01127         return;
01128         }
01129 
01130     /* check for double-freeing */
01131 check_dbl_free:
01132     for(i=0;i<MW_FREE_LIST;i++) {
01133         if( mwLastFree[i] == p ) {
01134             mwIncErr();
01135             mwWrite( "double-free: <%ld> %s(%d), %p was"
01136                 " freed from %s(%d)\n",
01137                 mwCounter, file, line, p,
01138                 mwLFfile[i], mwLFline[i] );
01139             FLUSH();
01140                         MW_MUTEX_UNLOCK();
01141             return;
01142             }
01143         }
01144 
01145     /* some weird pointer... block the free */
01146     mwIncErr();
01147     mwWrite( "WILD free: <%ld> %s(%d), unknown pointer %p\n",
01148         mwCounter, file, line, p );
01149     FLUSH();
01150         MW_MUTEX_UNLOCK();
01151     return;
01152     }

void mwFree_ ( void *   ) 

Definition at line 1163 of file KalFitMemLeak.c.

References MW_MUTEX_LOCK, MW_MUTEX_UNLOCK, and TESTS.

01163                         {
01164         MW_MUTEX_LOCK();
01165     TESTS(NULL,0);
01166         MW_MUTEX_UNLOCK();
01167     free(p);
01168     }

void mwFreeBufferInfo ( int  onoff  ) 

unsigned mwGrab ( unsigned  kilobytes  ) 

Definition at line 1372 of file KalFitMemLeak.c.

References MW_VAL_GRB, mwGrab_(), and TESTS.

01372                                {
01373     TESTS(NULL,0);
01374     return mwGrab_( kb, MW_VAL_GRB, 0 );
01375     }

int mwIsReadAddr ( const void *  p,
unsigned  len 
)

Definition at line 2491 of file KalFitMemLeak.c.

Referenced by mwIsOwned(), mwMark(), mwStatReport(), and mwTestBuf().

02492 {
02493     if( p == NULL ) return 0;
02494     if( len == 0 ) return 1;
02495     return 1;
02496 }

int mwIsSafeAddr ( void *  p,
unsigned  len 
)

Definition at line 2497 of file KalFitMemLeak.c.

Referenced by mwIsHeapOK(), mwIsOwned(), mwRelink(), mwTestBuf(), and mwTestNow().

02498 {
02499     if( p == NULL ) return 0;
02500     if( len == 0 ) return 1;
02501     return 1;
02502 }

void mwLimit ( long  bytes  ) 

Definition at line 1202 of file KalFitMemLeak.c.

References FLUSH, mwAllocLimit, mwUseLimit, mwWrite(), and TESTS.

01202                          {
01203     TESTS(NULL,0);
01204     mwWrite("limit: old limit = ");
01205     if( !mwAllocLimit ) mwWrite( "none" );
01206     else mwWrite( "%ld bytes", mwAllocLimit );
01207     mwWrite( ", new limit = ");
01208     if( !lim ) {
01209         mwWrite( "none\n" );
01210         mwUseLimit = 0;
01211         }
01212     else {
01213         mwWrite( "%ld bytes\n", lim );
01214         mwUseLimit = 1;
01215         }
01216     mwAllocLimit = lim;
01217     FLUSH();
01218     }

void* mwMalloc ( size_t  ,
const char *  ,
int   
)

Definition at line 863 of file KalFitMemLeak.c.

References CHKVAL, FLUSH, mw, MW_MUTEX_LOCK, MW_MUTEX_UNLOCK, MW_VAL_NEW, mwAllocLimit, mwAutoInit(), mwCounter, mwDataSize, mwFreeUp(), mwHead, mwIncErr(), mwNumCurAlloc, mwOverflowZoneSize, mwStatAlloc(), mwStatCurAlloc, mwStatLevel, mwStatMaxAlloc, mwStatNumAlloc, mwStatTotAlloc, mwTail, mwUseLimit, mwWrite(), mwWriteOF(), mwData_::prev, and TESTS.

00863                                                          {
00864     size_t needed;
00865     mwData *mw;
00866     char *ptr;
00867     void *p;
00868 
00869     mwAutoInit();
00870 
00871         MW_MUTEX_LOCK();
00872 
00873     TESTS(file,line);
00874 
00875     mwCounter ++;
00876     needed = mwDataSize + mwOverflowZoneSize*2 + size;
00877     if( needed < size )
00878     {
00879         /* theoretical case: req size + mw overhead exceeded size_t limits */
00880         return NULL;
00881     }
00882 
00883     /* if this allocation would violate the limit, fail it */
00884     if( mwUseLimit && ((long)size + mwStatCurAlloc > mwAllocLimit) ) {
00885         mwWrite( "limit fail: <%ld> %s(%d), %ld wanted %ld available\n",
00886             mwCounter, file, line, (long)size, mwAllocLimit - mwStatCurAlloc );
00887         mwIncErr();
00888         FLUSH();
00889                 MW_MUTEX_UNLOCK();
00890         return NULL;
00891         }
00892 
00893     mw = (mwData*) malloc( needed );
00894     if( mw == NULL ) {
00895         if( mwFreeUp(needed,0) >= needed ) {
00896             mw = (mwData*) malloc(needed);
00897             if( mw == NULL ) {
00898                 mwWrite( "internal: mwFreeUp(%u) reported success, but malloc() fails\n", needed );
00899                 mwIncErr();
00900                 FLUSH();
00901                 }
00902             }
00903         if( mw == NULL ) {
00904             mwWrite( "fail: <%ld> %s(%d), %ld wanted %ld allocated\n",
00905                 mwCounter, file, line, (long)size, mwStatCurAlloc );
00906             mwIncErr();
00907             FLUSH();
00908                         MW_MUTEX_UNLOCK();
00909             return NULL;
00910             }
00911         }
00912 
00913     mw->count = mwCounter;
00914     mw->prev = NULL;
00915     mw->next = mwHead;
00916     mw->file = file;
00917     mw->size = size;
00918     mw->line = line;
00919     mw->flag = 0;
00920     mw->check = CHKVAL(mw);
00921 
00922     if( mwHead ) mwHead->prev = mw;
00923     mwHead = mw;
00924     if( mwTail == NULL ) mwTail = mw;
00925 
00926     ptr = ((char*)mw) + mwDataSize;
00927         mwWriteOF( ptr ); /* '*(long*)ptr = PRECHK;' */
00928     ptr += mwOverflowZoneSize;
00929     p = ptr;
00930     memset( ptr, MW_VAL_NEW, size );
00931     ptr += size;
00932     mwWriteOF( ptr ); /* '*(long*)ptr = POSTCHK;' */
00933 
00934     mwNumCurAlloc ++;
00935     mwStatCurAlloc += (long) size;
00936     mwStatTotAlloc += (long) size;
00937     if( mwStatCurAlloc > mwStatMaxAlloc )
00938         mwStatMaxAlloc = mwStatCurAlloc;
00939     mwStatNumAlloc ++;
00940 
00941     if( mwStatLevel ) mwStatAlloc( size, file, line );
00942 
00943         MW_MUTEX_UNLOCK();
00944     return p;
00945     }

void* mwMalloc_ ( size_t   ) 

Definition at line 1170 of file KalFitMemLeak.c.

References MW_MUTEX_LOCK, MW_MUTEX_UNLOCK, and TESTS.

01170                                {
01171         MW_MUTEX_LOCK();
01172     TESTS(NULL,0);
01173         MW_MUTEX_UNLOCK();
01174     return malloc( size );
01175     }

void* mwMark ( void *  p,
const char *  description,
const char *  file,
unsigned  line 
)

Definition at line 718 of file KalFitMemLeak.c.

References mwMarker_::host, mwAutoInit(), mwFirstMark, mwIsReadAddr(), mwWrite(), mwMarker_::next, and TESTS.

00718                                                                             {
00719     mwMarker *mrk;
00720     unsigned n, isnew;
00721     char *buf;
00722     int tot, oflow = 0;
00723     char wherebuf[128];
00724 
00725     mwAutoInit();
00726     TESTS(NULL,0);
00727 
00728     if( desc == NULL ) desc = "unknown";
00729     if( file == NULL ) file = "unknown";
00730 
00731     tot = sprintf( wherebuf, "%.48s called from %s(%d)", desc, file, line );
00732     if( tot >= (int)sizeof(wherebuf) ) { wherebuf[sizeof(wherebuf)-1] = 0; oflow = 1; }
00733 
00734     if( p == NULL ) {
00735         mwWrite("mark: %s(%d), no mark for NULL:'%s' may be set\n", file, line, desc );
00736         return p;
00737         }
00738 
00739         if( mwFirstMark != NULL && !mwIsReadAddr( mwFirstMark, sizeof( mwMarker ) ) )
00740         {
00741                 mwWrite("mark: %s(%d), mwFirstMark (%p) is trashed, can't mark for %s\n",
00742                         file, line, mwFirstMark, desc );
00743                 return p;
00744         }
00745 
00746     for( mrk=mwFirstMark; mrk; mrk=mrk->next )
00747         {
00748                 if( mrk->next != NULL && !mwIsReadAddr( mrk->next, sizeof( mwMarker ) ) )
00749                 {
00750                         mwWrite("mark: %s(%d), mark(%p)->next(%p) is trashed, can't mark for %s\n",
00751                                 file, line, mrk, mrk->next, desc );
00752                         return p;
00753                 }
00754                 if( mrk->host == p ) break;
00755         }
00756 
00757     if( mrk == NULL ) {
00758         isnew = 1;
00759         mrk = (mwMarker*) malloc( sizeof( mwMarker ) );
00760         if( mrk == NULL ) {
00761             mwWrite("mark: %s(%d), no mark for %p:'%s', out of memory\n", file, line, p, desc );
00762             return p;
00763             }
00764                 mrk->next = NULL;
00765         n = 0;
00766         }
00767     else {
00768         isnew = 0;
00769         n = strlen( mrk->text );
00770         }
00771 
00772     n += strlen( wherebuf );
00773     buf = (char*) malloc( n+3 );
00774     if( buf == NULL ) {
00775         if( isnew ) free( mrk );
00776         mwWrite("mark: %s(%d), no mark for %p:'%s', out of memory\n", file, line, p, desc );
00777         return p;
00778         }
00779 
00780     if( isnew ) {
00781         memcpy( buf, wherebuf, n+1 );
00782         mrk->next = mwFirstMark;
00783         mrk->host = p;
00784         mrk->text = buf;
00785         mrk->level = 1;
00786         mwFirstMark = mrk;
00787         }
00788     else {
00789         strcpy( buf, mrk->text );
00790         strcat( buf, ", " );
00791         strcat( buf, wherebuf );
00792         free( mrk->text );
00793         mrk->text = buf;
00794         mrk->level ++;
00795         }
00796 
00797     if( oflow ) {
00798         mwIncErr();
00799         mwTrace( " [WARNING: OUTPUT BUFFER OVERFLOW - SYSTEM UNSTABLE]\n" );
00800         }
00801     return p;
00802     }

void mwNoMansLand ( int  mw_nml_level  ) 

Definition at line 1489 of file KalFitMemLeak.c.

References MW_NML_ALL, MW_NML_FREE, MW_NML_NONE, MW_VAL_NML, mwAutoInit(), mwDrop_(), mwGrab_(), mwNML, and TESTS.

01489                                {
01490     mwAutoInit();
01491     TESTS(NULL,0);
01492     switch( level ) {
01493         case MW_NML_NONE:
01494             (void) mwDrop_( 0, MW_VAL_NML, 0 );
01495             break;
01496         case MW_NML_FREE:
01497             break;
01498         case MW_NML_ALL:
01499             (void) mwGrab_( 0, MW_VAL_NML, 0 );
01500             break;
01501         default:
01502             return;
01503         }
01504     mwNML = level;
01505     }

void mwPuts ( const char *  text  ) 

void* mwRealloc ( void *  ,
size_t  ,
const char *  ,
int   
)

Definition at line 947 of file KalFitMemLeak.c.

References FLUSH, genRecEmupikp::i, mw, MW_FREE_LIST, MW_MUTEX_LOCK, MW_MUTEX_UNLOCK, MW_NML, MW_VAL_NML, mwAllocLimit, mwAutoInit(), mwBUFFER_TO_MW, mwCounter, mwDataSize, mwFree, mwIncErr(), mwIsOwned(), mwLastFree, mwLFfile, mwLFline, mwMalloc, mwOverflowZoneSize, mwStatCurAlloc, mwUseLimit, mwWrite(), and TESTS.

00947                                                                    {
00948     int oldUseLimit, i;
00949     mwData *mw;
00950     char *ptr;
00951 
00952     mwAutoInit();
00953 
00954     if( p == NULL ) return mwMalloc( size, file, line );
00955     if( size == 0 ) { mwFree( p, file, line ); return NULL; }
00956 
00957         MW_MUTEX_LOCK();
00958 
00959     /* do the quick ownership test */
00960     mw = (mwData*) mwBUFFER_TO_MW( p );
00961     if( mwIsOwned( mw, file, line ) ) {
00962 
00963                 /* if the buffer is an NML, treat this as a double-free */
00964                 if( mw->flag & MW_NML )
00965                 {
00966             mwIncErr();
00967                         if( *((unsigned char*)(mw)+mwDataSize+mwOverflowZoneSize) != MW_VAL_NML )
00968                         {
00969                                 mwWrite( "internal: <%ld> %s(%d), no-mans-land MW-%p is corrupted\n",
00970                                         mwCounter, file, line, mw );
00971                         }
00972                         goto check_dbl_free;
00973                 }
00974 
00975         /* if this allocation would violate the limit, fail it */
00976         if( mwUseLimit && ((long)size + mwStatCurAlloc - (long)mw->size > mwAllocLimit) ) {
00977             TESTS(file,line);
00978             mwCounter ++;
00979             mwWrite( "limit fail: <%ld> %s(%d), %ld wanted %ld available\n",
00980                 mwCounter, file, line, (unsigned long)size - mw->size, mwAllocLimit - mwStatCurAlloc );
00981             mwIncErr();
00982             FLUSH();
00983                         MW_MUTEX_UNLOCK();
00984             return NULL;
00985             }
00986 
00987         /* fake realloc operation */
00988         oldUseLimit = mwUseLimit;
00989         mwUseLimit = 0;
00990         ptr = (char*) mwMalloc( size, file, line );
00991         if( ptr != NULL ) {
00992             if( size < mw->size )
00993                 memcpy( ptr, p, size );
00994             else
00995                 memcpy( ptr, p, mw->size );
00996             mwFree( p, file, line );
00997             }
00998         mwUseLimit = oldUseLimit;
00999                 MW_MUTEX_UNLOCK();
01000         return (void*) ptr;
01001         }
01002 
01003     /* Unknown pointer! */
01004 
01005     /* using free'd pointer? */
01006 check_dbl_free:
01007     for(i=0;i<MW_FREE_LIST;i++) {
01008         if( mwLastFree[i] == p ) {
01009             mwIncErr();
01010             mwWrite( "realloc: <%ld> %s(%d), %p was"
01011                 " freed from %s(%d)\n",
01012                 mwCounter, file, line, p,
01013                 mwLFfile[i], mwLFline[i] );
01014             FLUSH();
01015                         MW_MUTEX_UNLOCK();
01016             return NULL;
01017             }
01018         }
01019 
01020     /* some weird pointer */
01021     mwIncErr();
01022     mwWrite( "realloc: <%ld> %s(%d), unknown pointer %p\n",
01023         mwCounter, file, line, p );
01024     FLUSH();
01025         MW_MUTEX_UNLOCK();
01026     return NULL;
01027     }

void* mwRealloc_ ( void *  ,
size_t   
)

Definition at line 1177 of file KalFitMemLeak.c.

References MW_MUTEX_LOCK, MW_MUTEX_UNLOCK, and TESTS.

01177                                          {
01178         MW_MUTEX_LOCK();
01179     TESTS(NULL,0);
01180         MW_MUTEX_UNLOCK();
01181     return realloc( p, size );
01182     }

void mwSetAriAction ( int  mw_ari_value  ) 

Definition at line 1220 of file KalFitMemLeak.c.

References MW_MUTEX_LOCK, MW_MUTEX_UNLOCK, mwAriAction, and TESTS.

01220                                   {
01221         MW_MUTEX_LOCK();
01222     TESTS(NULL,0);
01223     mwAriAction = action;
01224         MW_MUTEX_UNLOCK();
01225     return;
01226     }

void mwSetAriFunc ( int(*)(const char *)  func  ) 

Definition at line 854 of file KalFitMemLeak.c.

References mwAriFunction, and mwAutoInit().

00854                                                {
00855     mwAutoInit();
00856     mwAriFunction = func;
00857     }

void mwSetOutFunc ( void(*)(int)  func  ) 

Definition at line 655 of file KalFitMemLeak.c.

References mwAutoInit(), and mwOutFunction.

00655                                        {
00656     mwAutoInit();
00657     mwOutFunction = func;
00658     }

void mwStatistics ( int  level  ) 

Definition at line 637 of file KalFitMemLeak.c.

References mwAutoInit(), mwStatLevel, and mwWrite().

00638 {
00639     mwAutoInit();
00640     if( level<0 ) level=0;
00641     if( mwStatLevel != level )
00642     {
00643                 mwWrite( "statistics: now collecting on a %s basis\n",
00644                         level<1?"global":(level<2?"module":"line") );
00645             mwStatLevel = level;
00646         }
00647 }

char* mwStrdup ( const char *  ,
const char *  ,
int   
)

Definition at line 1029 of file KalFitMemLeak.c.

References FLUSH, MW_MUTEX_LOCK, MW_MUTEX_UNLOCK, mwCounter, mwIncErr(), mwMalloc, and mwWrite().

01029                                                               {
01030     size_t len;
01031     char *newstring;
01032 
01033         MW_MUTEX_LOCK();
01034 
01035     if( str == NULL ) {
01036         mwIncErr();
01037         mwWrite( "strdup: <%ld> %s(%d), strdup(NULL) called\n",
01038             mwCounter, file, line );
01039         FLUSH();
01040                 MW_MUTEX_UNLOCK();
01041         return NULL;
01042         }
01043 
01044     len = strlen( str ) + 1;
01045     newstring = (char*) mwMalloc( len, file, line );
01046     if( newstring != NULL ) memcpy( newstring, str, len );
01047         MW_MUTEX_UNLOCK();
01048     return newstring;
01049     }

void mwTerm ( void   ) 

Definition at line 625 of file KalFitMemLeak.c.

References mwAbort(), mwInited, and mwWrite().

00625                     {
00626     if( mwInited == 1 )
00627     {
00628         mwAbort();
00629         return;
00630     }
00631     if( !mwInited )
00632         mwWrite("internal: mwTerm(): MEMWATCH has not been started!\n");
00633     else
00634         mwInited --;
00635     }

int mwTest ( const char *  file,
int  line,
int  mw_test_flags 
)

Definition at line 685 of file KalFitMemLeak.c.

References mwAutoInit(), mwTestFlags, and mwTestNow().

00685                                                     {
00686     mwAutoInit();
00687     mwTestFlags = items;
00688     return mwTestNow( file, line, 0 );
00689     }

int mwTestBuffer ( const char *  file,
int  line,
void *  p 
)

Definition at line 695 of file KalFitMemLeak.c.

References mw, mwAutoInit(), mwBUFFER_TO_MW, mwIsOwned(), and mwTestBuf().

00695                                                         {
00696     mwData* mw;
00697 
00698     mwAutoInit();
00699 
00700     /* do the quick ownership test */
00701     mw = (mwData*) mwBUFFER_TO_MW( p );
00702 
00703     if( mwIsOwned( mw, file, line ) ) {
00704         return mwTestBuf( mw, file, line );
00705                 }
00706         return 1;
00707         }

void mwTrace ( const char *  format_string,
  ... 
)

Definition at line 1343 of file KalFitMemLeak.c.

References FLUSH, MW_MUTEX_LOCK, MW_MUTEX_UNLOCK, MW_TRACE_BUFFER, mwAutoInit(), mwDefaultOutFunc(), mwIncErr(), mwOutFunction, mwPrintBuf, mwTrace, and TESTS.

01343                                         {
01344     int tot, oflow = 0;
01345     va_list mark;
01346 
01347     mwAutoInit();
01348         MW_MUTEX_LOCK();
01349     TESTS(NULL,0);
01350     if( mwOutFunction == NULL ) mwOutFunction = mwDefaultOutFunc;
01351 
01352     va_start( mark, format );
01353     tot = vsprintf( mwPrintBuf, format, mark );
01354     va_end( mark );
01355     if( tot >= MW_TRACE_BUFFER ) { mwPrintBuf[MW_TRACE_BUFFER] = 0; oflow = 1; }
01356     for(tot=0;mwPrintBuf[tot];tot++)
01357         (*mwOutFunction)( mwPrintBuf[tot] );
01358     if( oflow ) {
01359         mwIncErr();
01360         mwTrace( " [WARNING: OUTPUT BUFFER OVERFLOW - SYSTEM UNSTABLE]\n" );
01361         }
01362 
01363     FLUSH();
01364         MW_MUTEX_UNLOCK();
01365     }

void* mwUnmark ( void *  p,
const char *  file,
unsigned  line 
)

Definition at line 804 of file KalFitMemLeak.c.

References mwMarker_::host, mwMarker_::level, mwFirstMark, mwWrite(), mwMarker_::next, and mwMarker_::text.

00804                                                            {
00805     mwMarker *mrk, *prv;
00806     mrk = mwFirstMark;
00807     prv = NULL;
00808     while( mrk ) {
00809         if( mrk->host == p ) {
00810             if( mrk->level < 2 ) {
00811                 if( prv ) prv->next = mrk->next;
00812                 else mwFirstMark = mrk->next;
00813                 free( mrk->text );
00814                 free( mrk );
00815                 return p;
00816                 }
00817             mrk->level --;
00818             return p;
00819             }
00820         prv = mrk;
00821         mrk = mrk->next;
00822         }
00823     mwWrite("mark: %s(%d), no mark found for %p\n", file, line, p );
00824     return p;
00825     }

int mwVerify ( int  ,
const char *  ,
const char *  ,
int   
)

Definition at line 1287 of file KalFitMemLeak.c.

References FLUSH, genRecEmupikp::i, MW_ARI_IGNORE, MW_ARI_NULLREAD, MW_MUTEX_LOCK, MW_MUTEX_UNLOCK, MW_TRACE_BUFFER, mwAriAction, mwAriFunction, mwAutoInit(), mwCounter, mwDummy(), mwIncErr(), mwSTDERR, mwTestNow(), mwWrite(), and TESTS.

01287                                                                   {
01288     int i;
01289     char buffer[MW_TRACE_BUFFER+8];
01290     if( exp ) {
01291         return 0;
01292         }
01293     mwAutoInit();
01294         MW_MUTEX_LOCK();
01295     TESTS(fn,ln);
01296     mwIncErr();
01297     mwCounter++;
01298     mwWrite( "verify trap: <%ld> %s(%d), %s\n", mwCounter, fn, ln, exps );
01299     if( mwAriFunction != NULL ) {
01300         sprintf( buffer, "MEMWATCH: verify trap: %s(%d), %s", fn, ln, exps );
01301         i = (*mwAriFunction)(buffer);
01302         if( i == 0 ) {
01303             mwWrite( "verify trap: <%ld> IGNORED - execution continues\n", mwCounter );
01304                         MW_MUTEX_UNLOCK();
01305             return 0;
01306             }
01307         if( i == 1 ) {
01308             mwWrite( "verify trap: <%ld> RETRY - executing again\n", mwCounter );
01309                         MW_MUTEX_UNLOCK();
01310             return 1;
01311             }
01312         }
01313     else {
01314         if( mwAriAction & MW_ARI_NULLREAD ) {
01315             /* This is made in an attempt to kick in */
01316             /* any debuggers or OS stack traces */
01317                     FLUSH();
01318             /*lint -save -e413 */
01319             i = *((int*)NULL);
01320                         mwDummy( (char)i );
01321             /*lint -restore */
01322             }
01323         if( mwAriAction & MW_ARI_IGNORE ) {
01324             mwWrite( "verify trap: <%ld> AUTO IGNORED - execution continues\n", mwCounter );
01325                         MW_MUTEX_UNLOCK();
01326             return 0;
01327             }
01328         fprintf(mwSTDERR,"\nMEMWATCH: verify trap: %s(%d), %s\n", fn, ln, exps );
01329         }
01330     FLUSH();
01331     (void) mwTestNow( fn, ln, 1 );
01332     FLUSH();
01333         MW_MUTEX_UNLOCK();
01334         exit(255);
01335     /* NOT REACHED - the return statement is in to keep */
01336     /* stupid compilers from squeaking about differing return modes. */
01337     /* Smart compilers instead say 'code unreachable...' */
01338     /*lint -save -e527 */
01339     return 0;
01340     /*lint -restore */
01341     }


Variable Documentation

const unsigned long mwCounter

Referenced by mwAssert(), mwDrop_(), mwFree(), mwIsOwned(), mwMalloc(), mwRealloc(), mwRelink(), mwStrdup(), mwTestBuf(), mwTestNow(), mwUnlink(), and mwVerify().


Generated on Tue Nov 29 23:16:52 2016 for BOSS_7.0.2 by  doxygen 1.4.7