Commit 180ce491 authored by Martin Åberg's avatar Martin Åberg Committed by Anas Nashif
Browse files

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: default avatarMartin Åberg <martin.aberg@gaisler.com>
parent 22c0d015
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ void *reallocarray(void *ptr, size_t nmemb, size_t size)
		errno = ENOMEM;
		return NULL;
	}
	return sys_heap_realloc(&z_malloc_heap, ptr, size);
	return realloc(ptr, size);
#else
	return NULL;
#endif