libc: minimal: fix realloc function

Excerpt from the manual:

  If ptr is NULL, then the call is equivalent to malloc(size) [...]

Without this commit, such calls end with a BUS FAULT.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
This commit is contained in:
Tomasz Gorochowik 2019-04-19 16:28:24 +02:00 committed by Anas Nashif
parent 4d9486fc22
commit 1afa9d0e5d
1 changed files with 4 additions and 0 deletions

View File

@ -102,6 +102,10 @@ void *realloc(void *ptr, size_t requested_size)
size_t block_size, total_requested_size;
void *new_ptr;
if (ptr == NULL) {
return malloc(requested_size);
}
if (requested_size == 0) {
return NULL;
}