forked from esp8266/Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
heap.c
83 lines (70 loc) · 1.62 KB
/
heap.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* heap.c - overrides of SDK heap handling functions
* Copyright (c) 2016 Ivan Grokhotkov. All rights reserved.
* This file is distributed under MIT license.
*/
#include <stdlib.h>
#include "umm_malloc/umm_malloc.h"
#include <c_types.h>
#include <sys/reent.h>
void* _malloc_r(struct _reent* unused, size_t size)
{
(void) unused;
return malloc(size);
}
void _free_r(struct _reent* unused, void* ptr)
{
(void) unused;
return free(ptr);
}
void* _realloc_r(struct _reent* unused, void* ptr, size_t size)
{
(void) unused;
return realloc(ptr, size);
}
void* _calloc_r(struct _reent* unused, size_t count, size_t size)
{
(void) unused;
return calloc(count, size);
}
void* ICACHE_RAM_ATTR pvPortMalloc(size_t size, const char* file, int line)
{
(void) file;
(void) line;
return malloc(size);
}
void ICACHE_RAM_ATTR vPortFree(void *ptr, const char* file, int line)
{
(void) file;
(void) line;
free(ptr);
}
void* ICACHE_RAM_ATTR pvPortCalloc(size_t count, size_t size, const char* file, int line)
{
(void) file;
(void) line;
return calloc(count, size);
}
void* ICACHE_RAM_ATTR pvPortRealloc(void *ptr, size_t size, const char* file, int line)
{
(void) file;
(void) line;
return realloc(ptr, size);
}
void* ICACHE_RAM_ATTR pvPortZalloc(size_t size, const char* file, int line)
{
(void) file;
(void) line;
return calloc(1, size);
}
size_t xPortGetFreeHeapSize(void)
{
return umm_free_heap_size();
}
size_t ICACHE_RAM_ATTR xPortWantedSizeAlign(size_t size)
{
return (size + 3) & ~((size_t) 3);
}
void system_show_malloc(void)
{
umm_info(NULL, 1);
}