ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/sm_list.c
(Generate patch)

Comparing ray/src/hd/sm_list.c (file contents):
Revision 3.3 by gwlarson, Wed Sep 16 18:16:28 1998 UTC vs.
Revision 3.8 by greg, Sat Feb 22 02:07:25 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  sm_list.c
6   *   Routines for handling linked generic linked lists, stack, and
# Line 20 | Line 17 | static LIST *free_lists = NULL;
17   extern int Malloc_cnt;  
18   #endif
19   LIST
20 + /* NOTE: Memory is not initialized */
21   *new_list()
22   {
23      LIST *l;
# Line 36 | Line 34 | LIST
34        if( !(l = (LIST *)malloc(sizeof(LIST))))
35            error(SYSTEM,"new_list():Unable to allocate memory");
36      }
39    /* clear the memory */
40    bzero(l, sizeof(LIST));
41
37      return(l);
38   }
39  
# Line 62 | Line 57 | LIST *a,*b;
57      return(b);
58   }
59  
60 + /* attaches list a at the end of list b */
61 + LIST
62 + *add_data(l,d,end)
63 + LIST *l;
64 + int d;
65 + LIST **end;
66 +
67 + {
68 +    LIST *list,*lptr;
69 +
70 +    list = new_list();
71 +    SET_LIST_DATA(list,d);
72 +    SET_LIST_NEXT(list,NULL);
73 +    if(!l)
74 +    {
75 +      if(end)
76 +        *end = list;
77 +      return(list);
78 +    }
79 +    if(end)
80 +      lptr = *end;
81 +    else
82 +    {
83 +      lptr = l;
84 +      while(LIST_NEXT(lptr))
85 +        lptr = LIST_NEXT(lptr);
86 +    }
87 +    LIST_NEXT(lptr) = list;
88 +    if(end)
89 +      *end = list;
90 +
91 +    return(l);
92 + }
93 +
94   /* Adds data to the end of a circular list. If set, "end"
95   * is a pointer to the last element in the list
96   */
# Line 90 | Line 119 | int d;
119      return(l);
120   }
121  
93 /* Pushes data element d at the top of the list- returns pointer
94   to new top of list
95 */
96 LIST
97 *push_data(l,d)
98 LIST *l;
99 int d;
100 {
101    LIST * list;
102    
103    list = new_list();
104    SET_LIST_DATA(list,d);
105    SET_LIST_NEXT(list,l);
106    return(list);
107 }
122  
123 +
124   /* frees the list */
125   LIST
126   *free_list(l)
# Line 119 | Line 134 | LIST * l;
134      return(NULL);
135   }
136  
137 + /* Pushes data element d at the top of the list- returns pointer
138 +   to new top of list
139 + */
140 + LIST
141 + *push_data(l,d)
142 + LIST *l;
143 + int d;
144 + {
145 +  LIST *list;
146 +
147 +  list = new_list();
148 +  SET_LIST_DATA(list,d);
149 +  SET_LIST_NEXT(list,l);
150 +  return(list);
151 + }
152   /* Returns data element d at the top of the list- returns pointer
153     to new top of list
154   */
# Line 175 | Line 205 | LIST **list;
205      }
206      return(FALSE);
207   }
208 +
209 +
210 +
211 +
212  
213  
214  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines