(open_socket): Use SOCK_CLOEXEC and SOCK_NONBLOCK if possible.
[glibc/history.git] / malloc / tst-trim1.c
blob310707e0e166f00882b327dd631936be00c9a43e
1 #include <malloc.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
6 #define N 10000
8 static void *arr[N];
10 static int
11 do_test (void)
13 for (int i = 0; i < N; ++i)
15 size_t size = random () % 16384;
17 if ((arr[i] = malloc (size)) == NULL)
19 nomem:
20 puts ("not enough memory");
21 return 0;
24 memset (arr[i], size, size);
27 void *p = malloc (256);
28 if (p == NULL)
29 goto nomem;
30 memset (p, 1, 256);
32 puts ("==================================================================");
34 for (int i = 0; i < N; ++i)
35 if (i % 13 != 0)
36 free (arr[i]);
38 puts ("==================================================================");
40 malloc_trim (0);
42 puts ("==================================================================");
44 p = malloc (30000);
45 if (p == NULL)
46 goto nomem;
48 memset (p, 2, 30000);
50 malloc_trim (0);
52 return 0;
55 #define TEST_FUNCTION do_test ()
56 #include "../test-skeleton.c"