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