Rizin
unix-like reverse engineering framework and cli tools
rz_alloc.h
Go to the documentation of this file.
1 #ifndef _R_UTIL_ALLOC_H_
2 #define _R_UTIL_ALLOC_H_ 1
3 
4 #include <rz_types.h>
5 #include <stdlib.h>
6 #include <stddef.h>
7 
8 #define RZ_MALLOC_WRAPPER 0
9 #define RZ_MALLOC_GLOBAL 0
10 
11 typedef void *(RMalloc)(size_t);
12 typedef void *(RCalloc)(size_t, size_t);
13 typedef void *(RRealloc)(void *, size_t);
14 typedef void(RFree)(void *);
15 
16 RZ_API void *rz_malloc_aligned(size_t size, size_t alignment);
17 RZ_API void rz_free_aligned(void *p);
18 
19 #if RZ_MALLOC_WRAPPER
20 
21 RZ_API void rz_alloc_hooks(RMalloc m, RCalloc c, RRealloc r, RFree f);
22 
23 #if RZ_MALLOC_GLOBAL
28 #define _r_malloc rz_malloc
29 #define _r_calloc rz_calloc
30 #define _r_free rz_free
31 #define _r_realloc rz_realloc
32 #else
33 RZ_API void *rz_malloc(size_t sz);
34 RZ_API void *rz_calloc(size_t count, size_t sz);
35 RZ_API void *rz_realloc(void *p, size_t sz);
36 RZ_API void rz_free(void *p);
37 #endif
38 
39 #else
40 
41 #define rz_malloc(x) malloc((x))
42 #define rz_calloc(x, y) calloc((x), (y))
43 #define rz_realloc(x, y) realloc((x), (y))
44 #define rz_free(x) free((x))
45 
46 #define _r_malloc rz_malloc
47 #define _r_calloc rz_calloc
48 #define _r_free rz_free
49 #define _r_realloc rz_realloc
50 
51 #endif
52 
53 #endif
#define RZ_API
#define r
Definition: crypto_rc6.c:12
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
Definition: sflib.h:98
voidpf void uLong size
Definition: ioapi.h:138
void * p
Definition: libc.cpp:67
#define rz_malloc(x)
Definition: rz_alloc.h:41
#define rz_free(x)
Definition: rz_alloc.h:44
void() RFree(void *)
Definition: rz_alloc.h:14
void *() RRealloc(void *, size_t)
Definition: rz_alloc.h:13
#define rz_realloc(x, y)
Definition: rz_alloc.h:43
RZ_API void rz_free_aligned(void *p)
Definition: alloc.c:73
RZ_API void * rz_malloc_aligned(size_t size, size_t alignment)
Definition: alloc.c:62
void *() RMalloc(size_t)
Definition: rz_alloc.h:11
#define rz_calloc(x, y)
Definition: rz_alloc.h:42
void *() RCalloc(size_t, size_t)
Definition: rz_alloc.h:12
#define f(i)
Definition: sha256.c:46
#define c(i)
Definition: sha256.c:43