MP-Gadget  5.0.1.dev1-76bc7d4726-dirty
mymalloc.h
Go to the documentation of this file.
1 #ifndef _MYMALLOC_H_
2 #define _MYMALLOC_H_
3 
4 #include "memory.h"
5 
6 extern Allocator A_MAIN[1];
7 extern Allocator A_TEMP[1];
8 
9 /* Initialize the main memory block*/
10 void mymalloc_init(double MemoryMB);
11 /* Initialize the small temporary memory block*/
12 void tamalloc_init(void);
13 void report_detailed_memory_usage(const char *label, const char * fmt, ...);
14 
15 #define mymalloc(name, size) allocator_alloc_bot(A_MAIN, name, size)
16 #define mymalloc2(name, size) allocator_alloc_top(A_MAIN, name, size)
17 
18 #define myrealloc(ptr, size) allocator_realloc(A_MAIN, ptr, size)
19 #define myfree(x) allocator_free(x)
20 
21 #define ma_malloc(name, type, nele) (type*) allocator_alloc_bot(A_MAIN, name, sizeof(type) * (nele))
22 #define ma_malloc2(name, type, nele) (type*) allocator_alloc_top(A_MAIN, name, sizeof(type) * (nele))
23 #define ma_free(p) allocator_free(p)
24 
25 #define ta_malloc(name, type, nele) (type*) allocator_alloc_bot(A_TEMP, name, sizeof(type) * (nele))
26 #define ta_malloc2(name, type, nele) (type*) allocator_alloc_top(A_TEMP, name, sizeof(type) * (nele))
27 #define ta_reset() allocator_reset(A_TEMP, 0)
28 #define ta_free(p) allocator_free(p)
29 
30 #define report_memory_usage(x) report_detailed_memory_usage(x, "%s:%d", __FILE__, __LINE__)
31 #define mymalloc_freebytes() allocator_get_free_size(A_MAIN)
32 #define mymalloc_usedbytes() allocator_get_used_size(A_MAIN, ALLOC_DIR_BOTH)
33 
34 #endif
Allocator A_TEMP[1]
Definition: mymalloc.c:22
void tamalloc_init(void)
Definition: mymalloc.c:29
void mymalloc_init(double MemoryMB)
Definition: mymalloc.c:48
void report_detailed_memory_usage(const char *label, const char *fmt,...)
Definition: mymalloc.c:75
Allocator A_MAIN[1]
Definition: mymalloc.c:17