libc/minimal: reallocarray() in terms of realloc()

reallocarray() is defined in terms of realloc(). From OpenBSD manual
pages:
    "Designed for safe allocation of arrays, the reallocarray()
    function is similar to realloc() except it operates on nmemb
    members of size size and checks for integer overflow in the
    calculation nmemb * size."

The return value of sys_heap_realloc() is not compatible with that
of realloc().

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
This commit is contained in:
Martin Åberg 2020-12-13 19:49:45 +01:00 committed by Anas Nashif
commit 180ce491ad

View file

@ -118,7 +118,7 @@ void *reallocarray(void *ptr, size_t nmemb, size_t size)
errno = ENOMEM; errno = ENOMEM;
return NULL; return NULL;
} }
return sys_heap_realloc(&z_malloc_heap, ptr, size); return realloc(ptr, size);
#else #else
return NULL; return NULL;
#endif #endif