mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/realloc' into 'master'
modify realloc behaves modify realloc behaves just like malloc when pass a null pointer for ptr. See merge request !66
This commit is contained in:
commit
fe3380d32e
@ -44,10 +44,17 @@ void _free_r(struct _reent *r, void* ptr) {
|
||||
return vPortFree(ptr);
|
||||
}
|
||||
|
||||
// TODO: improve realloc to grow buffer in place if possible
|
||||
void* _realloc_r(struct _reent *r, void* ptr, size_t size) {
|
||||
void* new_chunk = pvPortMalloc(size);
|
||||
if (new_chunk) {
|
||||
void* new_chunk;
|
||||
if (size == 0) {
|
||||
if (ptr) {
|
||||
vPortFree(ptr);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_chunk = pvPortMalloc(size);
|
||||
if (new_chunk && ptr) {
|
||||
memcpy(new_chunk, ptr, size);
|
||||
vPortFree(ptr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user