forked from simonask/ftl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathallocator.hpp
More file actions
40 lines (31 loc) · 861 Bytes
/
Copy pathallocator.hpp
File metadata and controls
40 lines (31 loc) · 861 Bytes
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
#pragma once
#ifndef ALLOCATOR_HPP_XE7VE834
#define ALLOCATOR_HPP_XE7VE834
#include <stdlib.h>
#define FTL_DEFAULT_ALLOCATOR MallocAllocator
namespace ftl {
class MallocAllocator {
public:
typedef unsigned char byte;
template <typename T>
static T* alloc(size_t n);
template <typename T>
static T* realloc(T* old, size_t n);
template <typename T>
static void free(T* ptr);
};
template <typename T>
inline T* MallocAllocator::alloc(size_t n) {
return static_cast<T*>(::malloc(sizeof(T)*n));
}
template <typename T>
inline T* MallocAllocator::realloc(T* old, size_t n) {
return static_cast<T*>(::realloc(old, sizeof(T)*n));
}
template <typename T>
inline void MallocAllocator::free(T* ptr) {
return ::free(ptr);
}
typedef FTL_DEFAULT_ALLOCATOR Allocator;
}
#endif /* end of include guard: ALLOCATOR_HPP_XE7VE834 */