1
6
7
13
14
18
19
20
21
22
26
27
31
32
36
37
41
42
46
47
51
52
56
57
58
59
60
61
64
65
66
69
70
71
72
76
77
81
82
98
99
102
105
106
111
112
116
117
121
122
125
126
130
131
136
137
138
139
/* ... */
#include <string.h>
#include <stdlib.h>
#include <sys/reent.h>
#include <errno.h>
#include <malloc.h>
#include "esp_heap_caps.h"6 includes
/* ... */
extern void *heap_caps_malloc_default(size_t size);
extern void *heap_caps_realloc_default(void *ptr, size_t size);
extern void *heap_caps_aligned_alloc_default(size_t alignment, size_t size);
void* malloc(size_t size)
{
return heap_caps_malloc_default(size);
}{ ... }
void* calloc(size_t n, size_t size)
{
return _calloc_r(_REENT, n, size);
}{ ... }
void* realloc(void* ptr, size_t size)
{
return heap_caps_realloc_default(ptr, size);
}{ ... }
void free(void *ptr)
{
heap_caps_free(ptr);
}{ ... }
void* _malloc_r(struct _reent *r, size_t size)
{
return heap_caps_malloc_default(size);
}{ ... }
void _free_r(struct _reent *r, void* ptr)
{
heap_caps_free(ptr);
}{ ... }
void* _realloc_r(struct _reent *r, void* ptr, size_t size)
{
return heap_caps_realloc_default(ptr, size);
}{ ... }
void* _calloc_r(struct _reent *r, size_t nmemb, size_t size)
{
void *result;
size_t size_bytes;
if (__builtin_mul_overflow(nmemb, size, &size_bytes)) {
return NULL;
}{...}
result = heap_caps_malloc_default(size_bytes);
if (result != NULL) {
bzero(result, size_bytes);
}{...}
return result;
}{ ... }
void* memalign(size_t alignment, size_t n)
{
return heap_caps_aligned_alloc_default(alignment, n);
}{ ... }
void* aligned_alloc(size_t alignment, size_t n)
{
return heap_caps_aligned_alloc_default(alignment, n);
}{ ... }
int posix_memalign(void **out_ptr, size_t alignment, size_t size)
{
if (size == 0) {
*out_ptr = NULL;
return 0;
}{...}
void *result = heap_caps_aligned_alloc_default(alignment, size);
if (result != NULL) {
*out_ptr = result;
return 0;
}{...}
return ENOMEM;
}{ ... }
/* ... */
void newlib_include_heap_impl(void)
{
}{ ... }
/* ... */
int malloc_trim(size_t pad)
{
return 0;
}{ ... }
size_t malloc_usable_size(void* p)
{
return 0;
}{ ... }
void malloc_stats(void)
{
}{ ... }
int mallopt(int parameter_number, int parameter_value)
{
return 0;
}{ ... }
struct mallinfo mallinfo(void)
{
struct mallinfo dummy = {0};
return dummy;
}{...}
void* valloc(size_t n) __attribute__((alias("malloc")));
void* pvalloc(size_t n) __attribute__((alias("malloc")));
void cfree(void* p) __attribute__((alias("free")));