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 |
17 |
|
extern int Malloc_cnt; |
18 |
|
#endif |
19 |
|
LIST |
20 |
+ |
/* NOTE: Memory is not initialized */ |
21 |
|
*new_list() |
22 |
|
{ |
23 |
|
LIST *l; |
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 |
|
|
69 |
|
|
70 |
|
list = new_list(); |
71 |
|
SET_LIST_DATA(list,d); |
72 |
< |
|
72 |
> |
SET_LIST_NEXT(list,NULL); |
73 |
|
if(!l) |
74 |
|
{ |
75 |
|
if(end) |
119 |
|
return(l); |
120 |
|
} |
121 |
|
|
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 |
– |
} |
122 |
|
|
123 |
+ |
|
124 |
|
/* frees the list */ |
125 |
|
LIST |
126 |
|
*free_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 |
|
*/ |
205 |
|
} |
206 |
|
return(FALSE); |
207 |
|
} |
208 |
+ |
|
209 |
+ |
|
210 |
+ |
|
211 |
+ |
|
212 |
|
|
213 |
|
|
214 |
|
|