File: list.c

package info (click to toggle)
splint 3.1.2.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 12,908 kB
  • ctags: 15,816
  • sloc: ansic: 150,306; yacc: 3,463; sh: 3,426; makefile: 2,217; lex: 412
file content (41 lines) | stat: -rw-r--r-- 682 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
typedef /*@null@*/ struct _list
{
  /*@only@*/ char *this;
  /*@null@*/ /*@only@*/ struct _list *next;
} *list;

extern /*@out@*/ /*@only@*/ void *
  smalloc (size_t);

void
list_addh (/*@temp@*/ list l, 
	   /*@only@*/ char *e)
{
  if (l != NULL)
    {
      while (l->next != NULL) 
	{
	  l = l->next;
	}
      
      l->next = (list) 
	smalloc (sizeof (*l->next));
      l->next->this = e;
    }
} /* l->next->next not defined */

void
list_addh2 (/*@temp@*/ list l, 
	    /*@only@*/ char *e)
{
  list new;

  assert (l != NULL);
  assert (l->next == NULL);

  new = (list) smalloc (sizeof (*l->next));
  new->this = e;
  l->next = new;
} /* l->next->next not defined */