|
22 | 22 | #else
|
23 | 23 | #define xmalloc(size) mrbc_raw_alloc(size)
|
24 | 24 | #define xcalloc(nmemb,size) mrbc_raw_calloc(nmemb, size)
|
25 |
| - #define xrealloc(ptr,size) mrbc_raw_realloc(ptr, size) |
26 |
| - #define xfree(ptr) mrbc_raw_free(ptr) |
| 25 | + #define xrealloc(nmemb,size) mrc_raw_realloc(nmemb, size) |
| 26 | + #define xfree(ptr) mrc_raw_free(ptr) |
27 | 27 |
|
28 | 28 | #define mrc_malloc(c,size) mrbc_raw_alloc(size)
|
29 | 29 | #define mrc_calloc(c,nmemb,size) mrbc_raw_calloc(nmemb, size)
|
30 |
| - #define mrc_realloc(c,ptr,size) mrbc_raw_realloc(ptr, size) |
31 |
| - #define mrc_free(c,ptr) mrbc_raw_free(ptr) |
| 30 | + #define mrc_realloc(c,ptr,size) mrc_raw_realloc(ptr, size) |
| 31 | + #define mrc_free(c,ptr) mrc_raw_free(ptr) |
| 32 | + |
| 33 | + static inline void mrc_raw_free(void *ptr) |
| 34 | + { |
| 35 | + /* mrbc_raw_free() warns when ptr=NULL but it should be allowed in C99 */ |
| 36 | + if (ptr == NULL) return; |
| 37 | + mrbc_raw_free(ptr); |
| 38 | + } |
| 39 | + |
| 40 | + static inline void* |
| 41 | + mrc_raw_realloc(void *ptr, unsigned int size) |
| 42 | + { |
| 43 | + /* mrbc_raw_realloc() fails when ptr=NULL but it should be allowed in C99 */ |
| 44 | + if (ptr == NULL) { |
| 45 | + return mrbc_raw_alloc(size); |
| 46 | + } else { |
| 47 | + return mrbc_raw_realloc(ptr, size); |
| 48 | + } |
| 49 | + } |
32 | 50 | #endif
|
33 | 51 | #else
|
34 | 52 |
|
|
0 commit comments