20 |
|
extern int Malloc_cnt; |
21 |
|
#endif |
22 |
|
LIST |
23 |
+ |
/* NOTE: Memory is not initialized */ |
24 |
|
*new_list() |
25 |
|
{ |
26 |
|
LIST *l; |
37 |
|
if( !(l = (LIST *)malloc(sizeof(LIST)))) |
38 |
|
error(SYSTEM,"new_list():Unable to allocate memory"); |
39 |
|
} |
39 |
– |
/* clear the memory */ |
40 |
– |
bzero(l, sizeof(LIST)); |
41 |
– |
|
40 |
|
return(l); |
41 |
|
} |
42 |
|
|
72 |
|
|
73 |
|
list = new_list(); |
74 |
|
SET_LIST_DATA(list,d); |
75 |
< |
|
75 |
> |
SET_LIST_NEXT(list,NULL); |
76 |
|
if(!l) |
77 |
|
{ |
78 |
|
if(end) |
122 |
|
return(l); |
123 |
|
} |
124 |
|
|
127 |
– |
/* Pushes data element d at the top of the list- returns pointer |
128 |
– |
to new top of list |
129 |
– |
*/ |
130 |
– |
LIST |
131 |
– |
*push_data(l,d) |
132 |
– |
LIST *l; |
133 |
– |
int d; |
134 |
– |
{ |
135 |
– |
LIST * list; |
136 |
– |
|
137 |
– |
list = new_list(); |
138 |
– |
SET_LIST_DATA(list,d); |
139 |
– |
SET_LIST_NEXT(list,l); |
140 |
– |
return(list); |
141 |
– |
} |
125 |
|
|
126 |
+ |
|
127 |
|
/* frees the list */ |
128 |
|
LIST |
129 |
|
*free_list(l) |
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 |
|
*/ |
208 |
|
} |
209 |
|
return(FALSE); |
210 |
|
} |
211 |
+ |
|
212 |
+ |
|
213 |
+ |
|
214 |
+ |
|
215 |
|
|
216 |
|
|
217 |
|
|