1 | |
2 | // vim:sw=2:ai |
3 | |
4 | /* |
5 | * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. |
6 | * Copyright (C) 2011-2017 Kentoku SHIBA |
7 | * See COPYRIGHT.txt for details. |
8 | */ |
9 | |
10 | #ifndef DENA_ALLOCATOR_HPP |
11 | #define DENA_ALLOCATOR_HPP |
12 | |
13 | #if 0 |
14 | extern "C" { |
15 | #include <tlsf.h> |
16 | }; |
17 | #define DENA_MALLOC(x) tlsf_malloc(x) |
18 | #define DENA_REALLOC(x, y) tlsf_realloc(x, y) |
19 | #define DENA_FREE(x) tlsf_free(x) |
20 | #define DENA_NEWCHAR(x) static_cast<char *>(tlsf_malloc(x)) |
21 | #define DENA_DELETE(x) tlsf_free(x) |
22 | #endif |
23 | |
24 | #if 1 |
25 | #define DENA_MALLOC(x) malloc(x) |
26 | #define DENA_REALLOC(x, y) realloc(x, y) |
27 | #define DENA_FREE(x) free(x) |
28 | #define DENA_NEWCHAR(x) (new char[x]) |
29 | #define DENA_DELETE(x) (delete [] x) |
30 | #endif |
31 | |
32 | #if 1 |
33 | #define DENA_ALLOCA_ALLOCATE(typ, len) \ |
34 | (typ *) (alloca((len) * sizeof(typ))) |
35 | #define DENA_ALLOCA_FREE(x) |
36 | #else |
37 | #define DENA_ALLOCA_ALLOCATE(typ, len) \ |
38 | (typ *) (malloc((len) * sizeof(typ))) |
39 | #define DENA_ALLOCA_FREE(x) free(x) |
40 | #endif |
41 | |
42 | #endif |
43 | |
44 | |