-
Notifications
You must be signed in to change notification settings - Fork 2
/
allocator.h
44 lines (30 loc) · 958 Bytes
/
allocator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef ALLOCATOR_H_
#define ALLOCATOR_H_
#include <stdint.h>
#include <string.h>
/* In order to integrate NightWatch, the memory allocator
* should support the following interface. */
extern void* tc_malloc_internal(size_t size, int type);
extern void tc_free_internal(void *p);
extern void switch_heap_type(void *p, size_t size, int target_type);
extern void set_extend_info(void *p, void *extend_info);
extern void* get_extend_info(void *p);
static inline
void* internal_malloc(int type, size_t size) {
return tc_malloc_internal(size, type);
}
static inline
void* internal_calloc(int type, size_t n, size_t elem_size) {
size_t size = n * elem_size;
void *p = tc_malloc_internal(size, type);
memset(p, 0, size);
return p;
}
static inline
void internal_free(void *p) {
return tc_free_internal(p);
}
extern void enter_cache_management();
extern void leave_cache_management();
extern int in_cache_management();
#endif /* ALLOCATOR_H_ */