-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlibc_allocator.cpp
More file actions
executable file
·57 lines (47 loc) · 873 Bytes
/
libc_allocator.cpp
File metadata and controls
executable file
·57 lines (47 loc) · 873 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
46
47
48
49
50
51
52
53
54
55
56
57
#include<iostream>
#include<cstdlib>
#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 - 1;
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) ;
}
};