IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32174


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)

Location:
trunk/psLib/src/sys
Files:
2 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");
  • trunk/psLib/src/sys/psMemory.h

    r31660 r32174  
    367367    bool persistence                   ///< make check across all object even persistent ones
    368368);
     369int psMemCheckLeaks2(
     370    psMemId id0,                       ///< don't list blocks with id < id0
     371    psMemBlock ***array,               ///< pointer to array of pointers to leaked blocks, or NULL
     372    FILE * fd,                         ///< print list of leaks to fd (or NULL)
     373    bool persistence,                  ///< make check across all object even persistent ones
     374    int maxDisplayedLeaksCount         ///< List at most maxDisplayedLeaksCount (-1 for all)
     375);
    369376#else // ifdef DOXYGEN
    370377int p_psMemCheckLeaks(
     
    375382    psMemBlock ***array,                ///< pointer to array of pointers to leaked blocks, or NULL
    376383    FILE * fd,                          ///< print list of leaks to fd (or NULL)
    377     bool persistence                    ///< make check across all object even persistent ones
    378 );
    379 #ifndef SWIG
     384    bool persistence,                   ///< make check across all object even persistent ones
     385    int maxDisplayedLeaksCount          ///< List at most maxDisplayedLeaksCount (-1 for all)
     386);
     387#ifndef SWIG
     388#define psMemCheckLeaks2(id0, array, fd, persistence, maxDisplayedLeaksCount) \
     389      p_psMemCheckLeaks(__FILE__, __LINE__, __func__, id0, array, fd, persistence, maxDisplayedLeaksCount)
    380390#define psMemCheckLeaks(id0, array, fd, persistence) \
    381       p_psMemCheckLeaks(__FILE__, __LINE__, __func__, id0, array, fd, persistence)
     391      p_psMemCheckLeaks(__FILE__, __LINE__, __func__, id0, array, fd, persistence, 500)
    382392#endif // ifndef SWIG
    383393#endif // ifdef DOXYGEN
Note: See TracChangeset for help on using the changeset viewer.