Changeset 19553
- Timestamp:
- Sep 15, 2008, 11:24:30 AM (18 years ago)
- Location:
- trunk/Nebulous/nebclient/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous/nebclient/src/xmalloc.c
r4677 r19553 4 4 * Copyright (C) 2003-2005 Joshua Hoblitt, 2003 Robert Lupton 5 5 * 6 * $Id: xmalloc.c,v 1. 3 2005-07-30 02:45:31jhoblitt Exp $6 * $Id: xmalloc.c,v 1.4 2008-09-15 21:24:30 jhoblitt Exp $ 7 7 */ 8 8 … … 11 11 #include "xmalloc.h" 12 12 13 //#define USE_EFF 1 14 #ifdef USE_EFF 15 #include "efence.h" 16 #endif 17 13 18 /*****************************************************************************/ 14 19 /* 15 20 * Wrappers for malloc/free. xmalloc cannot fail. 16 21 */ 17 void * xmalloc(size_t n) 22 void * x_xmalloc( 23 const char *file, 24 unsigned int lineno, 25 const char *func, 26 size_t n) 18 27 { 28 #ifdef USE_EFF 29 void *ptr = _eff_malloc(n, file, lineno); 30 #else 19 31 void *ptr = malloc(n); 32 #endif 20 33 21 34 if (ptr == NULL) { … … 27 40 } 28 41 29 void * xrealloc(void *ptr, size_t size) 42 void * x_xrealloc( 43 const char *file, 44 unsigned int lineno, 45 const char *func, 46 void *ptr, 47 size_t size) 30 48 { 49 #ifdef USE_EFF 50 void *newptr = _eff_realloc(ptr, size, file, lineno); 51 #else 31 52 void *newptr = realloc(ptr, size); 53 #endif 32 54 33 55 if (!newptr) { … … 39 61 } 40 62 41 void xfree(void *ptr) 63 void x_xfree( 64 const char *file, 65 unsigned int lineno, 66 const char *func, 67 void *ptr) 42 68 { 69 #ifdef USE_EFF 70 _eff_free(ptr, file, lineno); 71 #else 43 72 free(ptr); 73 #endif 44 74 } -
trunk/Nebulous/nebclient/src/xmalloc.h
r4677 r19553 4 4 * Copyright (C) 2003-2005 Joshua Hoblitt, 2003 Robert Lupton 5 5 * 6 * $Id: xmalloc.h,v 1. 4 2005-07-30 02:45:31jhoblitt Exp $6 * $Id: xmalloc.h,v 1.5 2008-09-15 21:24:30 jhoblitt Exp $ 7 7 */ 8 8 … … 10 10 #define XMALLOC_H 1 11 11 12 void * xmalloc(size_t n); 12 #define xmalloc(size) \ 13 x_xmalloc(__FILE__, __LINE__, __func__, size) 13 14 14 void * xrealloc(void *ptr, size_t size); 15 void * 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) \ 28 x_xrealloc(__FILE__, __LINE__, __func__, ptr, size) 29 30 void * 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__ 15 41 16 void xfree(void *ptr); 42 #define xfree(ptr) \ 43 x_xfree(__FILE__, __LINE__, __func__, ptr) 44 45 void 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 ); 17 51 18 52 #endif // XMALLOC_H
Note:
See TracChangeset
for help on using the changeset viewer.
