1 #include <stdlib.h> 2 #include <string.h> 3 #include <errno.h> 4 #include <sys/resource.h> 5 #include "test.h" 6 t_memfill()7int t_memfill() 8 { 9 int r = 0; 10 /* alloc mmap space with PROT_NONE */ 11 if (t_vmfill(0,0,0) < 0) { 12 t_error("vmfill failed: %s\n", strerror(errno)); 13 r = -1; 14 } 15 /* limit brk space */ 16 if (t_setrlim(RLIMIT_DATA, 0) < 0) 17 r = -1; 18 if (!r) 19 /* use up libc reserves if any */ 20 while (malloc(1)); 21 return r; 22 } 23