-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlibc_allocator.cpp
More file actions
45 lines (36 loc) · 862 Bytes
/
libc_allocator.cpp
File metadata and controls
45 lines (36 loc) · 862 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
41
42
43
44
45
// Copyright (c) 2012 MIT License by 6.172 Staff
#include "./allocator_interface.h"
namespace my {
/* Libc needs no initialization. */
int libc_allocator::init() {
return 0;
}
/* Libc has no heap checker, so we just return true. */
int libc_allocator::check() {
return 0;
}
/* Libc can't be reset. */
void libc_allocator::reset_brk() {
}
/* Return NULL for the minimum pointer value.*/
void * libc_allocator::heap_lo() {
return NULL;
}
/* Return NULL.
This probably isn't portable. */
void * libc_allocator::heap_hi() {
return NULL;
}
/*call default malloc */
void * libc_allocator::malloc(size_t size) {
return std::malloc(size);
}
/*call default realloc */
void * libc_allocator::realloc(void *ptr, size_t size) {
return std::realloc(ptr, size);
}
/*call default realloc */
void libc_allocator::free(void *ptr) {
std::free(ptr);
}
};