1 /* Copyright (c) 2015 Regents of the University of California
3 * Author: Brian Demsky <bdemsky@uci.edu>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
11 * @brief Memory allocation functions.
14 #ifndef CSAT_MY_MEMORY_H
15 #define CSAT_MY_MEMORY_H
23 void * ourmalloc(size_t size);
24 void ourfree(void *ptr);
25 void * ourcalloc(size_t count, size_t size);
26 void * ourrealloc(void *ptr, size_t size);
29 void * model_malloc(size_t size);
30 void model_free(void *ptr);
31 void * model_calloc(size_t count, size_t size);
32 void * model_realloc(void *ptr, size_t size);
35 #define ourmalloc model_malloc
36 #define ourfree model_free
37 #define ourrealloc model_realloc
38 #define ourcalloc model_calloc
41 static inline void *ourmalloc(size_t size) { return malloc(size); }
42 static inline void ourfree(void *ptr) { free(ptr); }
43 static inline void *ourcalloc(size_t count, size_t size) { return calloc(count, size); }
44 static inline void *ourrealloc(void *ptr, size_t size) { return realloc(ptr, size); }
47 void *operator new(size_t size) { \
48 return ourmalloc(size); \
50 void operator delete(void *p, size_t size) { \
53 void *operator new[](size_t size) { \
54 return ourmalloc(size); \
56 void operator delete[](void *p, size_t size) { \
59 void *operator new(size_t size, void *p) { /* placement new */ \
63 #endif/* _MY_MEMORY_H */