IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29680


Ignore:
Timestamp:
Nov 5, 2010, 9:50:55 AM (16 years ago)
Author:
eugene
Message:

added a psStringRealloc function; replaced the call to psRealloc in psSlurp with psStringRealloc (so free function is correctly set)

Location:
branches/eam_branches/ipp-20101103/psLib/src/sys
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101103/psLib/src/sys/psSlurp.c

    r12072 r29680  
    3838        // increase the allocated string size
    3939        size += SLURP_SIZE;
    40         str = psRealloc(str, size);
     40        str = psStringRealloc(str, size);
    4141
    4242        // read a block from the stream
  • branches/eam_branches/ipp-20101103/psLib/src/sys/psString.c

    r19070 r29680  
    4848    psString string = p_psAlloc(file, lineno, func, nChar + 1);
    4949    psMemSetDeallocator(string, (psFreeFunc)stringFree);
     50
     51    return string;
     52}
     53
     54
     55psString p_psStringRealloc(const char *file,
     56                           unsigned int lineno,
     57                           const char *func,
     58                           psString string,
     59                           size_t nChar)
     60{
     61    if (!string) {
     62        string = p_psAlloc(file, lineno, func, nChar + 1);
     63        psMemSetDeallocator(string, (psFreeFunc)stringFree);
     64    } else {
     65        string = p_psRealloc(file, lineno, func, string, nChar + 1);
     66    }
    5067
    5168    return string;
  • branches/eam_branches/ipp-20101103/psLib/src/sys/psString.h

    r15523 r29680  
    4040#define PS_FILE_LINE p_psFileLine(__FILE__,__LINE__)
    4141
    42 
    4342/** Allocates a new psString.
    4443 *
     
    6059#endif // ifdef DOXYGEN
    6160
     61/** Reallocate an existing psString (or alloc if not existent)
     62 *
     63 *  @return psString:       string of length n.
     64 */
     65#ifdef DOXYGEN
     66psString psStringRealloc(
     67    psString string,
     68    size_t nChar                        ///< Size of psString to allocate.
     69);
     70#else // ifdef DOXYGEN
     71psString p_psStringRealloc(
     72    const char *file,                   ///< File of caller
     73    unsigned int lineno,                ///< Line number of caller
     74    const char *func,                   ///< Function name of caller
     75    psString string,                    ///< supplied string or NULL
     76    size_t nChar                        ///< Size of psString to allocate.
     77) PS_ATTR_MALLOC;
     78#define psStringRealloc(string, nChar)                          \
     79    p_psStringRealloc(__FILE__, __LINE__, __func__, string, nChar)
     80#endif // ifdef DOXYGEN
    6281
    6382/** Checks the type of a particular pointer.
Note: See TracChangeset for help on using the changeset viewer.