5
* Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
6
* See COPYRIGHT.txt for details.
9
#ifndef DENA_ALLOCATOR_HPP
10
#define DENA_ALLOCATOR_HPP
19
#define DENA_MALLOC(x) tlsf_malloc(x)
20
#define DENA_REALLOC(x, y) tlsf_realloc(x, y)
21
#define DENA_FREE(x) tlsf_free(x)
22
#define DENA_NEWCHAR(x) static_cast<char *>(tlsf_malloc(x))
23
#define DENA_DELETE(x) tlsf_free(x)
24
typedef std::allocator<int> allocator_type;
28
#define DENA_MALLOC(x) malloc(x)
29
#define DENA_REALLOC(x, y) realloc(x, y)
30
#define DENA_FREE(x) free(x)
31
#define DENA_NEWCHAR(x) (new char[x])
32
#define DENA_DELETE(x) (delete [] x)
33
typedef std::allocator<int> allocator_type;
37
#define DENA_ALLOCA_ALLOCATE(typ, len) \
38
static_cast<typ *>(alloca((len) * sizeof(typ)))
39
#define DENA_ALLOCA_FREE(x)
41
#define DENA_ALLOCA_ALLOCATE(typ, len) \
42
static_cast<typ *>(malloc((len) * sizeof(typ)))
43
#define DENA_ALLOCA_FREE(x) free(x)
48
template <typename T> struct auto_alloca_free {
49
auto_alloca_free(T *value) : value(value) { }
51
/* no-op if alloca() is used */
52
DENA_ALLOCA_FREE(value);
55
auto_alloca_free(const auto_alloca_free&);
56
auto_alloca_free& operator =(const auto_alloca_free&);