[beken-72xx] Use realloc() based on malloc()

This commit is contained in:
Kuba Szczodrzyński
2023-04-22 18:29:52 +02:00
parent 42c18859f3
commit c5361a4738
2 changed files with 14 additions and 21 deletions

View File

@@ -28,34 +28,26 @@ void *__wrap_calloc(size_t num, size_t size) {
}
void *__wrap_realloc(void *ptr, size_t new_size) {
#if LT_REMALLOC
void *nptr = pvPortMalloc(new_size);
if (nptr) {
memcpy(nptr, ptr, new_size);
vPortFree(ptr);
}
return nptr;
#else
return LT_REALLOC_FUNC(ptr, new_size);
#endif
}
void __wrap_free(void *ptr) {
vPortFree(ptr);
}
void *__wrap__malloc_r(void *reent, size_t size) {
return pvPortMalloc(size);
}
void *__wrap__calloc_r(void *reent, size_t num, size_t size) {
void *ptr;
if (num == 0 || size == 0)
num = size = 1;
ptr = pvPortMalloc(num * size);
if (ptr)
memset(ptr, 0, num * size);
return ptr;
}
void *__wrap__realloc_r(void *reent, void *ptr, size_t new_size) {
return LT_REALLOC_FUNC(ptr, new_size);
}
void __wrap__free_r(void *reent, void *ptr) {
vPortFree(ptr);
}
__attribute__((alias("__wrap_malloc"))) void *__wrap__malloc_r(void *reent, size_t size);
__attribute__((alias("__wrap_calloc"))) void *__wrap__calloc_r(void *reent, size_t num, size_t size);
__attribute__((alias("__wrap_realloc"))) void *__wrap__realloc_r(void *reent, void *ptr, size_t new_size);
__attribute__((alias("__wrap_free"))) void __wrap__free_r(void *reent, void *ptr);
#endif