home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lclint.zip / lclint-2_3h-os2-bin.zip / test / list.c < prev    next >
C/C++ Source or Header  |  1997-09-03  |  618b  |  42 lines

  1. typedef /*@null@*/ struct _list
  2. {
  3.   /*@only@*/ char *this;
  4.   /*@null@*/ /*@only@*/ struct _list *next;
  5. } *list;
  6.  
  7. extern /*@out@*/ /*@only@*/ void *
  8.   smalloc (size_t);
  9.  
  10. void
  11. list_addh (/*@temp@*/ list l, 
  12.        /*@only@*/ char *e)
  13. {
  14.   if (l != NULL)
  15.     {
  16.       while (l->next != NULL) 
  17.     {
  18.       l = l->next;
  19.     }
  20.       
  21.       l->next = (list) 
  22.     smalloc (sizeof (*l->next));
  23.       l->next->this = e;
  24.     }
  25. }
  26.  
  27. void
  28. list_addh2 (/*@temp@*/ list l, 
  29.         /*@only@*/ char *e)
  30. {
  31.   list new;
  32.  
  33.   assert (l != NULL);
  34.   assert (l->next == NULL);
  35.  
  36.   new = (list) smalloc (sizeof (*l->next));
  37.   new->this = e;
  38.   l->next = new;
  39. }
  40.  
  41.       
  42.