/* * Report whether this machine's malloc() correctly returns NULL when * a memory request cannot be satisfied. My machine (glibc 2.0.5c) * does have this bug. */ #include #include #include int main(void) { const char * const p = malloc(ULONG_MAX); /* Expect NULL. */ /* If p != NULL, malloc() is surely lying. */ printf("Returned pointer: %p (should be %p).\n", p, (void *) 0); if (p) printf("Either you have 4 GB free RAM, or your malloc() has a bug.\n"); else printf("malloc() returned NULL. Your malloc() is OK.\n"); return 0; }