IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 6, 2007, 3:15:50 PM (19 years ago)
Author:
jhoblitt
Message:

change psFree() macro to *NOT* cast all pointers to (void *)
change psFree() macro to not append a ';' to the line
change all psMemory functions to pass file, lineno, func as the first 3 params

File:
1 edited

Legend:

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

    r11672 r11674  
    1010*  @author Joshua Hoblitt, University of Hawaii
    1111*
    12 *  @version $Revision: 1.93 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2007-02-07 00:36:02 $
     12*  @version $Revision: 1.94 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2007-02-07 01:15:49 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    355355}
    356356
    357 int p_psMemCheckCorruption(FILE *output,
    358                            bool abort_on_error,
    359                            const char *file,
     357int p_psMemCheckCorruption(const char *file,
    360358                           unsigned int lineno,
    361                            const char *func)
     359                           const char *func,
     360                           FILE *output,
     361                           bool abort_on_error)
    362362{
    363363    // get exclusive access to the memBlock list to avoid it changing on us
     
    385385}
    386386
     387
    387388/*
    388389 * Set whether allocated memory is persistent
     
    400401}
    401402
     403
    402404/*
    403405 * Actually allocate memory
    404406 */
    405 void *p_psAlloc(size_t size,
    406                 const char *file,
     407void *p_psAlloc(const char *file,
    407408                unsigned int lineno,
    408                 const char *func)
     409                const char *func,
     410                size_t size)
    409411{
    410412
     
    490492}
    491493
    492 void *p_psRealloc(void *ptr,
    493                   size_t size,
    494                   const char *file,
     494
     495void *p_psRealloc(const char *file,
    495496                  unsigned int lineno,
    496                   const char *func)
     497                  const char *func,
     498                  void *ptr,
     499                  size_t size)
    497500{
    498501    if (ptr == NULL) {
    499         return p_psAlloc(size, file, lineno, func);
     502        return p_psAlloc(file, lineno, func, size);
    500503    }
    501504
     
    565568 * Check for memory leaks.
    566569 */
    567 int p_psMemCheckLeaks(psMemId id0,
     570int p_psMemCheckLeaks(const char *file,
     571                      unsigned int lineno,
     572                      const char *func,
     573                      psMemId id0,
    568574                      psMemBlock ***array,
    569575                      FILE * fd,
    570                       bool persistence,
    571                       const char *file,
    572                       unsigned int lineno,
    573                       const char *func)
     576                      bool persistence)
    574577{
    575578    psS32 nleak = 0;
     
    579582    // make sure that the memblock list is free of corruption before we crawl
    580583    // the list
    581     p_psMemCheckCorruption(fd, true, file, lineno, func);
     584    p_psMemCheckCorruption(file, lineno, func, fd, true);
    582585
    583586    MUTEX_LOCK(&memBlockListMutex);
     
    675678}
    676679
     680
    677681/*
    678682 * Reference counting APIs
    679683 */
    680 
    681 // return refCounter
    682 psReferenceCount p_psMemGetRefCounter(void *ptr,
    683                                       const char *file,
     684psReferenceCount p_psMemGetRefCounter(const char *file,
    684685                                      unsigned int lineno,
    685                                       const char *func)
     686                                      const char *func,
     687                                      void *ptr)
    686688{
    687689    if (ptr == NULL) {
     
    696698}
    697699
     700
    698701// increment and return refCounter
    699 void *p_psMemIncrRefCounter(void *ptr,
    700                             const char *file,
     702void *p_psMemIncrRefCounter(const char *file,
    701703                            unsigned int lineno,
    702                             const char *func)
     704                            const char *func,
     705                            void *ptr)
    703706{
    704707    if (ptr == NULL) {
     
    721724    return ptr;
    722725}
     726
    723727
    724728#if 0
     
    755759#endif
    756760
     761
    757762// decrement and return refCounter
    758 void *p_psMemDecrRefCounter(void * ptr,
    759                             const char *file,
     763void *p_psMemDecrRefCounter(const char *file,
    760764                            unsigned int lineno,
    761                             const char *func)
     765                            const char *func,
     766                            void * ptr)
    762767{
    763768    if (ptr == NULL) {
     
    823828}
    824829
    825 void p_psMemSetDeallocator(void *ptr,
    826                            psFreeFunc freeFunc,
    827                            const char *file,
     830
     831void p_psMemSetDeallocator(const char *file,
    828832                           unsigned int lineno,
    829                            const char *func)
     833                           const char *func,
     834                           void *ptr,
     835                           psFreeFunc freeFunc)
    830836{
    831837    if (ptr == NULL) {
     
    840846}
    841847
    842 psFreeFunc p_psMemGetDeallocator(void *ptr,
    843                                  const char *file,
     848
     849psFreeFunc p_psMemGetDeallocator(const char *file,
    844850                                 unsigned int lineno,
    845                                  const char *func)
     851                                 const char *func,
     852                                 void *ptr)
    846853{
    847854    if (ptr == NULL) {
     
    856863}
    857864
     865
    858866bool psMemSetThreadSafety(bool safe)
    859867{
     
    868876}
    869877
     878
    870879bool psMemGetThreadSafety(void)
    871880{
     
    879888}
    880889
    881 bool p_psMemGetPersistent(void *ptr,
    882                           const char *file,
     890
     891bool p_psMemGetPersistent(const char *file,
    883892                          unsigned int lineno,
    884                           const char *func)
     893                          const char *func,
     894                          void *ptr)
    885895{
    886896    if (ptr == NULL) {
     
    895905}
    896906
    897 void p_psMemSetPersistent(void *ptr,
    898                           bool value,
    899                           const char *file,
     907
     908void p_psMemSetPersistent(const char *file,
    900909                          unsigned int lineno,
    901                           const char *func)
     910                          const char *func,
     911                          void *ptr,
     912                          bool value)
    902913{
    903914    if (ptr == NULL) {
     
    912923}
    913924
    914 /************************************************************************************************************/
    915 /*
    916  * Return the total amount of memory owned by psLib; if non-NULL also provide a breakdown
    917  * into recyclable, allocated, and allocated-and-persistent
     925
     926/******************************************************************************/
     927/*
     928 * Return the total amount of memory owned by psLib; if non-NULL also provide a
     929 * breakdown into recyclable, allocated, and allocated-and-persistent
    918930 *
    919  * It would be simple enough to fix this code to return an array of structs to describe
    920  * the insides of the allocator rather than the printf used here.
     931 * It would be simple enough to fix this code to return an array of structs to
     932 * describe the insides of the allocator rather than the printf used here.
    921933 */
    922934size_t psMemStats(const bool print, // print details as they're found?
Note: See TracChangeset for help on using the changeset viewer.