uselocale(0) regression test
[libc-test.git] / src / regression / flockfile-list.c
blob09f18ffc059a9da2ca7f973095310ee1f277f774
1 // commit: 3e936ce81bbbcc968f576aedbd5203621839f152 2014-09-19
2 // flockfile linked list handling was broken
3 #include <errno.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include "test.h"
9 int main()
11 FILE *f = tmpfile();
12 FILE *g = tmpfile();
13 flockfile(g);
14 flockfile(f);
15 funlockfile(g);
16 fclose(g);
18 /* fill memory */
19 if (t_vmfill(0,0,0) < 0)
20 t_error("vmfill failed: %s\n", strerror(errno));
21 size_t i,n;
22 unsigned char *p;
23 for (n = 1; n < 10000; n++) {
24 if (!(p=malloc(n))) break;
25 free(p);
27 n--;
28 if (!(p=malloc(n))) {
29 t_error("bad malloc fragmentation\n");
30 return t_status;
32 memset(p, 0xff, n);
34 /* may corrupt memory */
35 funlockfile(f);
36 for (i=0; i<n; i++) {
37 if (p[i]!=0xff) {
38 t_error("p[%zu] = %.2x\n", i, p[i]);
41 return t_status;