OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [libmudflap/] [testsuite/] [libmudflap.c/] [heap-scalestress.c] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 275 jeremybenn
/* zz30
2
 *
3
 * demonstrate a splay-tree depth problem
4
*/
5
 
6
#include <stdlib.h>
7
#include <stdio.h>
8
#include <unistd.h>
9
 
10
#ifndef SCALE
11
#define SCALE 100000
12
#endif
13
 
14
 
15
struct list
16
{
17
  struct list *next;
18
};
19
 
20
 
21
int
22
main ()
23
{
24
  struct list *head = NULL;
25
  struct list *tail = NULL;
26
  struct list *p;
27
  long n;
28
  int direction;
29
 
30
  for (direction = 0; direction < 2; direction++)
31
    {
32
      fprintf (stdout, "allocating\n");
33
      fflush (stdout);
34
 
35
      for (n = 0; n < SCALE; ++n)
36
        {
37
          p = malloc (sizeof *p);
38
          if (NULL == p)
39
            {
40
              fprintf (stdout, "malloc failed\n");
41
              break;
42
            }
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;
51
            }
52
          else
53
            {                   /* add at head */
54
              p->next = head;
55
              if (NULL == tail)
56
                tail = p;
57
              head = p;
58
            }
59
        }
60
 
61
      fprintf (stdout, "freeing\n");
62
      fflush (stdout);
63
 
64
      while (NULL != head)
65
        {
66
          p = head;
67
          head = head->next;
68
          free (p);
69
        }
70
 
71
    }
72
 
73
  fprintf (stdout, "done\n");
74
  fflush (stdout);
75
 
76
  return (0);
77
}
78
 
79
/* { dg-output "allocating.*freeing.*allocating.*freeing.*done" } */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.