wasi-libc/libc-bottom-half/sources/reallocarray.c
Dan Gohman 753cc4344d
Merge the basics component into libc-bottom-half. (#199)
We no longer have a need to maintain basics as a separate component.
Folding it into libc-bottom-half eliminates a fair amount of redundancy.
2020-06-01 16:44:05 -07:00

15 lines
379 B
C

#include <stdlib.h>
#include <errno.h>
void *__reallocarray(void *ptr, size_t nmemb, size_t size) {
size_t bytes;
if (__builtin_umull_overflow(nmemb, size, &bytes)) {
errno = ENOMEM;
return NULL;
}
return realloc(ptr, bytes);
}
void *reallocarray(void *ptr, size_t nmemb, size_t size)
__attribute__((__weak__, __alias__("__reallocarray")));