switch to C
[satune.git] / src / mymemory.h
1 /*      Copyright (c) 2015 Regents of the University of California
2  *
3  *      Author: Brian Demsky <bdemsky@uci.edu>
4  *
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.
8  */
9
10 /** @file mymemory.h
11  *  @brief Memory allocation functions.
12  */
13
14 #ifndef _MY_MEMORY_H
15 #define _MY_MEMORY_H
16 #include <limits.h>
17 #include <stddef.h>
18 #include <stdlib.h>
19
20 #include "config.h"
21
22 /** MEMALLOC declares the allocators for a class to allocate
23  *      memory in the non-snapshotting heap. */
24 /*
25 #define MEMALLOC                                                                                 \
26         void * operator new(size_t size) { \
27                 return model_malloc(size); \
28         } \
29         void operator delete(void *p, size_t size) { \
30                 model_free(p);                                   \
31         } \
32         void * operator new[](size_t size) { \
33                 return model_malloc(size); \
34         } \
35         void operator delete[](void *p, size_t size) { \
36                 model_free(p); \
37         } \
38         void * operator new(size_t size, void *p) {     \
39                 return p;                                                                                                                                                               \
40         }
41 */
42
43 void * ourmalloc(size_t size);
44 void ourfree(void *ptr);
45 void * ourcalloc(size_t count, size_t size);
46 void * ourrealloc(void *ptr, size_t size);
47
48 void *model_malloc(size_t size);
49 void *model_calloc(size_t count, size_t size);
50 void * model_realloc(void *ptr, size_t size);
51 void model_free(void *ptr);
52
53 #endif/* _MY_MEMORY_H */