Files
linux-kernel-module-cheat/baremetal/out_of_memory.c
2019-05-21 00:00:00 +00:00

19 lines
335 B
C

/* Test out of memory. */
#include <stdio.h>
#include <stdlib.h>
int main(void) {
char *ptr = NULL;
size_t alloc_size = 1;
while (1) {
ptr = realloc(ptr, alloc_size);
if (ptr == NULL) {
puts("out of memory");
break;
} else {
alloc_size <<= 1;
}
}
}