IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 23, 2011, 10:04:37 AM (15 years ago)
Author:
Serge CHASTEL
Message:

Added psMemCheckLeaks2() in which the number of leaks to be displayed can be set. psMemCheckLeaks keeps its default behavior (500 displayed messages)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sys/psMemory.c

    r31660 r32174  
    889889                      psMemBlock ***array,
    890890                      FILE * fd,
    891                       bool persistence)
     891                      bool persistence,
     892                      int maxDisplayedLeaksCount          ///< List at most maxDisplayedLeaksCount (-1 for all)
     893                  )
    892894{
    893895    psS32 nleak = 0;
     
    915917    for (memBlock = topBlock; memBlock->nextBlock != NULL; memBlock = memBlock->nextBlock) { }
    916918
     919    int maxToDisplay = maxDisplayedLeaksCount;
     920    psMemBlock *memBlockBackup = memBlock;
     921    if (maxToDisplay == -1 ) {
     922      for (; memBlock != NULL; memBlock = memBlock->previousBlock) {
     923        if ( (memBlock->refCounter > 0) &&
     924             ( (persistence) || (!persistence && !memBlock->persistent) ) &&
     925             (memBlock->id >= id0)) {
     926          nleak++;
     927        }
     928      }
     929      maxToDisplay=nleak;
     930    }
     931    fprintf(stderr,"maxToDisplay: %d\n", maxToDisplay);
     932    memBlock = memBlockBackup;
     933
     934    nleak=0;
    917935    // iterate through the block list starting with the oldest block
    918936    for (; memBlock != NULL; memBlock = memBlock->previousBlock) {
     
    924942
    925943            // only print a max of 500 leaks (make this an argument)
    926             if ((nleak < 500) && (fd != NULL)) {
     944            if ( (nleak <= maxToDisplay) && (fd != NULL) ) {
    927945                if (nleak == 1) {
    928946                    fprintf(fd, "# func at (file:line)  ID: X  Ref: X\n");
Note: See TracChangeset for help on using the changeset viewer.