-
Notifications
You must be signed in to change notification settings - Fork 0
/
mymalloc.h
59 lines (47 loc) · 1.98 KB
/
mymalloc.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef _MYMALLOC_H_
#define _MYMALLOC_H_
#include <stdint.h>
#include <sys/mman.h>
#define LOGPREFIX "[---] "
#define REGPREFIX "[+++] "
#define PRINTLOG 1
extern void calc_peak(size_t);
extern uint32_t peak;
extern uint32_t max_peak;
extern void* (*libc_malloc)(size_t);
extern void (*libc_free)(void*);
extern void* (*libc_realloc)(void*, size_t);
extern void* (*libc_calloc)(size_t, size_t);
extern void* (*libc_valloc)(size_t);
extern void* (*libc_pvalloc)(size_t);
extern void* (*libc_memalign)(size_t, size_t);
extern void *(*libmman_mmap)(void*, size_t, int, int, int, off_t);
extern void* (*libmman_mmap64) (void *, size_t, int, int, int, off64_t);
extern int (*libmman_munmap)(void*, size_t);
extern void* (*libmman_mremap) (void *, size_t, size_t, int, void *);
extern int (*exit_real)(int);
extern void* mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
extern void* mmap64(void *addr, size_t length, int prot, int flags, int fd, off64_t offset);
extern int munmap(void *addr, size_t length);
extern void* mremap(void *addr, size_t old_length, size_t length, int flags, ...);
extern void* malloc(size_t size);
extern void free(void *ptr);
extern void* realloc(void* ptr, size_t size);
extern void* calloc(size_t nmemb, size_t size);
extern void* valloc(size_t size);
extern void* pvalloc(size_t size);
extern void* memalign(size_t alignment, size_t size);
extern int posix_memalign(void **memptr, size_t alignment, size_t size);
extern void exit(int status);
/* Internals */
extern void* __libc_malloc(size_t size);
extern void __libc_free(void *ptr);
extern void* __libc_realloc(void* ptr, size_t size);
extern void* __libc_calloc(size_t nmemb, size_t size);
extern void* __libc_valloc(size_t size);
extern void* __libc_pvalloc(size_t size);
extern void* __libc_memalign(size_t alignment, size_t size);
extern int __libc_posix_memalign(void **memptr, size_t alignment, size_t size);
extern void _exit(int status);
extern void _Exit(int status);
#endif /* _MYMALLOC_H_ */