Add missing zstd.h to coregrind Makefile.am noinst_HEADERS
[valgrind.git] / memcheck / tests / linux / enomem.c
blob05cc08cd52d832084d2ab8bcb9d75075f506e916
2 /* Test malloc, calloc, realloc and memalign set errno to ENOMEM */
4 #include <errno.h>
5 #include <limits.h>
6 #include <malloc.h>
7 #include <stdio.h>
8 #include <stdlib.h>
10 int main ( void )
12 char* small = malloc (16);
13 char* p;
15 errno = 0;
16 p = malloc(SSIZE_MAX);
17 if (!p && errno == ENOMEM) puts("malloc: Cannot allocate memory");
19 errno = 0;
20 p = calloc(1, SSIZE_MAX);
21 if (!p && errno == ENOMEM) puts("calloc: Cannot allocate memory");
23 errno = 0;
24 p = realloc(small, SSIZE_MAX);
25 if (!p && errno == ENOMEM) puts("realloc: Cannot allocate memory");
27 errno = 0;
28 p = memalign(64, SSIZE_MAX);
29 if (!p && errno == ENOMEM) puts("memalign: Cannot allocate memory");
31 free(small);
33 return 0;