summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/reallocarray.c
blob: 4dd1a6c8df6c32511510da24c64d980a7b9ed418 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdlib.h>
#include <errno.h>
#include <linux/errno.h>
#include <malloc.h>

void *reallocarray(void *ptr, size_t nmemb, size_t size)
{
	size_t total = nmemb * size;
	if (nmemb != 0 && total / nmemb != size) {
		errno = ENOMEM;
		return NULL;
	}
	return realloc(ptr, total);
}