-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompat.h
39 lines (34 loc) · 1.08 KB
/
compat.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
#ifndef FWM_COMPAT
#define FWM_COMPAT
#ifndef __GNUC__
#define __typeof__ typeof
#endif
/* Override FWM_MALLOC to use malloc implementation of choice e.g. xmalloc or
* kmalloc. This is used by map(), filter() to allocate new arrays. FWM_MALLOC
* should resolve to a function.
*/
#ifndef FWM_MALLOC
#define FWM_MALLOC malloc
#endif
#ifndef FWM_FREE
#define FWM_FREE free
#endif
/* Override FWM_MALLOC_FMT if your malloc implementation of choice requires
* arguments besides the size. e.g. your customer malloc's prototype is
* void * my_malloc(size_t size, char *debug_string_to_track_allocations)
* So if you
* #define FWM_MALLOC my_malloc
* #define FWM_MALLOC_FMT(size) (size, __func__)
* all allocations made by map(), filter() etc, will call my_malloc(some_size,
* __func__) during allocations.
*
* Of course this doesn't gracefully work if you want to vary the format
* between allocations..but we'll cross that bridge when we reach it.
*/
#ifndef FWM_MALLOC_FMT
#define FWM_MALLOC_FMT(size) (size)
#endif
#ifndef FWM_FREE_FMT
#define FWM_FREE_FMT(ptr) (ptr)
#endif
#endif