Add missing zstd.h to coregrind Makefile.am noinst_HEADERS
[valgrind.git] / memcheck / tests / amd64-linux / reallocarray.c
blobce63b80100da41b446a00c3d43f13ff4e48d6967
1 #include <stdlib.h>
2 #include <assert.h>
3 #include <errno.h>
4 #include <stdint.h>
5 #include <malloc.h>
6 #include "../../memcheck.h"
8 int main(void)
10 int *pi = NULL;
11 VALGRIND_DO_LEAK_CHECK;
12 pi = reallocarray(pi, 10U, sizeof(int));
13 VALGRIND_DO_ADDED_LEAK_CHECK;
14 pi = reallocarray(pi, 0U, sizeof(int));
15 VALGRIND_DO_ADDED_LEAK_CHECK;
16 pi = malloc(10U);
17 pi = reallocarray(pi, 10U, 0U);
18 VALGRIND_DO_CHANGED_LEAK_CHECK;
19 pi = NULL;
20 pi = reallocarray(pi, 10U, sizeof(int));
21 VALGRIND_DO_ADDED_LEAK_CHECK;
22 errno = 0;
23 pi = reallocarray(pi, 1UL << 49, 1U);
24 assert(!pi);
25 assert(errno == ENOMEM);
26 VALGRIND_DO_CHANGED_LEAK_CHECK;
27 pi = reallocarray(pi, SIZE_MAX/1000U, SIZE_MAX/1000U);
28 assert(!pi);
29 assert(errno == ENOMEM);
30 VALGRIND_DO_CHANGED_LEAK_CHECK;