Skip to content

Commit 180ce49

Browse files
tbr-ttnashif
authored andcommitted
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 <[email protected]>
1 parent 22c0d01 commit 180ce49

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/libc/minimal/source/stdlib/malloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void *reallocarray(void *ptr, size_t nmemb, size_t size)
118118
errno = ENOMEM;
119119
return NULL;
120120
}
121-
return sys_heap_realloc(&z_malloc_heap, ptr, size);
121+
return realloc(ptr, size);
122122
#else
123123
return NULL;
124124
#endif

0 commit comments

Comments
 (0)