* config/m68k/m68k.c (notice_update_cc): Use SET_DEST and
[official-gcc.git] / libmudflap / testsuite / libmudflap.c / heap-scalestress.c
blob2d51731d611ec2b9059be22a1e21f6282bcf6afb
1 /* zz30
3 * demonstrate a splay-tree depth problem
4 */
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <unistd.h>
10 #ifndef SCALE
11 #define SCALE 100000
12 #endif
15 struct list
17 struct list *next;
21 int
22 main ()
24 struct list *head = NULL;
25 struct list *tail = NULL;
26 struct list *p;
27 long n;
28 int direction;
30 for (direction = 0; direction < 2; direction++)
32 fprintf (stdout, "allocating\n");
33 fflush (stdout);
35 for (n = 0; n < SCALE; ++n)
37 p = malloc (sizeof *p);
38 if (NULL == p)
40 fprintf (stdout, "malloc failed\n");
41 break;
43 if (direction == 0)
44 { /* add at tail */
45 p->next = NULL;
46 if (NULL != tail)
47 tail->next = p;
48 else
49 head = p;
50 tail = p;
52 else
53 { /* add at head */
54 p->next = head;
55 if (NULL == tail)
56 tail = p;
57 head = p;
61 fprintf (stdout, "freeing\n");
62 fflush (stdout);
64 while (NULL != head)
66 p = head;
67 head = head->next;
68 free (p);
73 fprintf (stdout, "done\n");
74 fflush (stdout);
76 return (0);
79 /* { dg-output "allocating.*freeing.*allocating.*freeing.*done" } */