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.1 by gwlarson, Wed Aug 19 17:45:24 1998 UTC vs.
Revision 3.7 by gwlarson, Thu Jun 10 15:22:23 1999 UTC

# Line 20 | Line 20 | static LIST *free_lists = NULL;
20   extern int Malloc_cnt;  
21   #endif
22   LIST
23 + /* NOTE: Memory is not initialized */
24   *new_list()
25   {
26      LIST *l;
27  
27
28
28      /* check free list for available edges */
29      if( free_lists )
30      {
# Line 38 | Line 37 | LIST
37        if( !(l = (LIST *)malloc(sizeof(LIST))))
38            error(SYSTEM,"new_list():Unable to allocate memory");
39      }
41    /* clear the memory */
42    bzero(l, sizeof(LIST));
43
40      return(l);
41   }
42  
# Line 52 | Line 48 | LIST *a,*b;
48   {
49      LIST * l;
50  
55    if(!a)
56      return(b);
57
51      if(!b)
52         return(a);
53      
# Line 67 | Line 60 | LIST *a,*b;
60      return(b);
61   }
62  
63 + /* attaches list a at the end of list b */
64 + LIST
65 + *add_data(l,d,end)
66 + LIST *l;
67 + int d;
68 + LIST **end;
69 +
70 + {
71 +    LIST *list,*lptr;
72 +
73 +    list = new_list();
74 +    SET_LIST_DATA(list,d);
75 +    SET_LIST_NEXT(list,NULL);
76 +    if(!l)
77 +    {
78 +      if(end)
79 +        *end = list;
80 +      return(list);
81 +    }
82 +    if(end)
83 +      lptr = *end;
84 +    else
85 +    {
86 +      lptr = l;
87 +      while(LIST_NEXT(lptr))
88 +        lptr = LIST_NEXT(lptr);
89 +    }
90 +    LIST_NEXT(lptr) = list;
91 +    if(end)
92 +      *end = list;
93 +
94 +    return(l);
95 + }
96 +
97   /* Adds data to the end of a circular list. If set, "end"
98   * is a pointer to the last element in the list
99   */
# Line 95 | Line 122 | int d;
122      return(l);
123   }
124  
98 /* Pushes data element d at the top of the list- returns pointer
99   to new top of list
100 */
101 LIST
102 *push_data(l,d)
103 LIST *l;
104 int d;
105 {
106    LIST * list;
107    
108    list = new_list();
109    SET_LIST_DATA(list,d);
110    SET_LIST_NEXT(list,l);
111    return(list);
112 }
125  
126 +
127   /* frees the list */
128   LIST
129   *free_list(l)
# Line 118 | Line 131 | LIST * l;
131   {
132      if(!l)
133         return(NULL);
134 +
135      free_lists = append_list(free_lists,l);
136  
137      return(NULL);
138   }
139  
140 + /* Pushes data element d at the top of the list- returns pointer
141 +   to new top of list
142 + */
143 + LIST
144 + *push_data(l,d)
145 + LIST *l;
146 + int d;
147 + {
148 +  LIST *list;
149 +
150 +  list = new_list();
151 +  SET_LIST_DATA(list,d);
152 +  SET_LIST_NEXT(list,l);
153 +  return(list);
154 + }
155   /* Returns data element d at the top of the list- returns pointer
156     to new top of list
157   */
# Line 131 | Line 160 | pop_list(l)
160   LIST **l;
161   {
162      LIST *p;
163 <    void *d;
163 >    int d;
164      
165      if(!l)
166         return(NULL);
# Line 179 | Line 208 | LIST **list;
208      }
209      return(FALSE);
210   }
211 +
212 +
213 +
214 +
215  
216  
217  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines