IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19553


Ignore:
Timestamp:
Sep 15, 2008, 11:24:30 AM (18 years ago)
Author:
jhoblitt
Message:

add efence hooks

Location:
trunk/Nebulous/nebclient/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous/nebclient/src/xmalloc.c

    r4677 r19553  
    44 * Copyright (C) 2003-2005  Joshua Hoblitt, 2003  Robert Lupton
    55 *
    6  * $Id: xmalloc.c,v 1.3 2005-07-30 02:45:31 jhoblitt Exp $
     6 * $Id: xmalloc.c,v 1.4 2008-09-15 21:24:30 jhoblitt Exp $
    77 */
    88
     
    1111#include "xmalloc.h"
    1212
     13//#define USE_EFF 1
     14#ifdef USE_EFF
     15#include "efence.h"
     16#endif
     17
    1318/*****************************************************************************/
    1419/*
    1520 * Wrappers for malloc/free.  xmalloc cannot fail.
    1621 */
    17 void * xmalloc(size_t n)
     22void * x_xmalloc(
     23                const char *file,
     24                unsigned int lineno,
     25                const char *func,
     26                size_t n)
    1827{
     28#ifdef USE_EFF
     29   void *ptr = _eff_malloc(n, file, lineno);
     30#else
    1931   void *ptr = malloc(n);
     32#endif
    2033   
    2134   if (ptr == NULL) {
     
    2740}
    2841
    29 void * xrealloc(void *ptr, size_t size)
     42void * x_xrealloc(
     43                const char *file,
     44                unsigned int lineno,
     45                const char *func,
     46                void *ptr,
     47                size_t size)
    3048{
     49#ifdef USE_EFF
     50    void *newptr = _eff_realloc(ptr, size, file, lineno);
     51#else
    3152    void *newptr = realloc(ptr, size);
     53#endif
    3254
    3355    if (!newptr) {
     
    3961}
    4062 
    41 void xfree(void *ptr)
     63void x_xfree(
     64            const char *file,
     65            unsigned int lineno,
     66            const char *func,
     67            void *ptr)
    4268{
     69#ifdef USE_EFF
     70    _eff_free(ptr, file, lineno);
     71#else
    4372   free(ptr);
     73#endif
    4474}
  • trunk/Nebulous/nebclient/src/xmalloc.h

    r4677 r19553  
    44 * Copyright (C) 2003-2005  Joshua Hoblitt, 2003  Robert Lupton
    55 *
    6  * $Id: xmalloc.h,v 1.4 2005-07-30 02:45:31 jhoblitt Exp $
     6 * $Id: xmalloc.h,v 1.5 2008-09-15 21:24:30 jhoblitt Exp $
    77 */
    88
     
    1010#define XMALLOC_H 1
    1111
    12 void * xmalloc(size_t n);
     12#define xmalloc(size) \
     13x_xmalloc(__FILE__, __LINE__, __func__, size)
    1314
    14 void * xrealloc(void *ptr, size_t size);
     15void * x_xmalloc(
     16    const char *file,                  ///< File of caller
     17    unsigned int lineno,               ///< Line number of caller
     18    const char *func,                  ///< Function name of caller
     19    size_t n
     20#ifdef __GNUC__
     21) __attribute__((malloc));
     22# else // ifdef __GNUC__
     23);
     24#endif // ifdef __GNUC__
     25
     26
     27#define xrealloc(ptr, size) \
     28x_xrealloc(__FILE__, __LINE__, __func__, ptr, size)
     29
     30void * x_xrealloc(
     31    const char *file,                  ///< File of caller
     32    unsigned int lineno,               ///< Line number of caller
     33    const char *func,                  ///< Function name of caller
     34    void *ptr,
     35    size_t size
     36#ifdef __GNUC__
     37) __attribute__((malloc));
     38# else // ifdef __GNUC__
     39);
     40#endif // ifdef __GNUC__
    1541 
    16 void xfree(void *ptr);
     42#define xfree(ptr) \
     43x_xfree(__FILE__, __LINE__, __func__, ptr)
     44
     45void x_xfree(
     46    const char *file,                  ///< File of caller
     47    unsigned int lineno,               ///< Line number of caller
     48    const char *func,                  ///< Function name of caller
     49    void *ptr
     50);
    1751
    1852#endif // XMALLOC_H
Note: See TracChangeset for help on using the changeset viewer.