-
Notifications
You must be signed in to change notification settings - Fork 23
/
tlsf-malloc.c
46 lines (40 loc) · 1.05 KB
/
tlsf-malloc.c
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
#include "irq.h"
#include "tlsf-malloc.h"
#include <string.h>
void *TLSF_MALLOC_NAME(malloc)(size_t bytes)
{
unsigned old_state = irq_disable();
void *result = tlsf_malloc(bytes);
irq_restore(old_state);
return result;
}
void *TLSF_MALLOC_NAME(calloc)(size_t count, size_t bytes)
{
unsigned old_state = irq_disable();
void *result = tlsf_malloc(count * bytes);
if (result) {
memset(result, 0, count * bytes);
}
irq_restore(old_state);
return result;
}
void *TLSF_MALLOC_NAME(memalign)(size_t align, size_t bytes)
{
unsigned old_state = irq_disable();
void *result = tlsf_memalign(align, bytes);
irq_restore(old_state);
return result;
}
void *TLSF_MALLOC_NAME(realloc)(void *ptr, size_t size)
{
unsigned old_state = irq_disable();
void *result = tlsf_realloc(ptr, size);
irq_restore(old_state);
return result;
}
void TLSF_MALLOC_NAME(free)(void *ptr)
{
unsigned old_state = irq_disable();
tlsf_free(ptr);
irq_restore(old_state);
}