Mercurial > hg > early-roguelike
comparison arogue5/list.c @ 218:56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
This still leaves over a thousand lines of warning messages, mostly
related to the return types of daemons and fuses.
author | John "Elwin" Edwards |
---|---|
date | Sun, 07 Feb 2016 14:39:21 -0500 |
parents | 0ed67132cf10 |
children | 0250220d8cdd |
comparison
equal
deleted
inserted
replaced
217:94a0d9dd5ce1 | 218:56e748983fa8 |
---|---|
19 /* | 19 /* |
20 * detach: | 20 * detach: |
21 * Takes an item out of whatever linked list it might be in | 21 * Takes an item out of whatever linked list it might be in |
22 */ | 22 */ |
23 | 23 |
24 _detach(list, item) | 24 void |
25 register struct linked_list **list, *item; | 25 _detach(struct linked_list **list, struct linked_list *item) |
26 { | 26 { |
27 if (*list == item) | 27 if (*list == item) |
28 *list = next(item); | 28 *list = next(item); |
29 if (prev(item) != NULL) item->l_prev->l_next = next(item); | 29 if (prev(item) != NULL) item->l_prev->l_next = next(item); |
30 if (next(item) != NULL) item->l_next->l_prev = prev(item); | 30 if (next(item) != NULL) item->l_next->l_prev = prev(item); |
35 /* | 35 /* |
36 * _attach: | 36 * _attach: |
37 * add an item to the head of a list | 37 * add an item to the head of a list |
38 */ | 38 */ |
39 | 39 |
40 _attach(list, item) | 40 void |
41 register struct linked_list **list, *item; | 41 _attach(struct linked_list **list, struct linked_list *item) |
42 { | 42 { |
43 if (*list != NULL) | 43 if (*list != NULL) |
44 { | 44 { |
45 item->l_next = *list; | 45 item->l_next = *list; |
46 (*list)->l_prev = item; | 46 (*list)->l_prev = item; |
58 /* | 58 /* |
59 * o_free_list: | 59 * o_free_list: |
60 * Throw the whole object list away | 60 * Throw the whole object list away |
61 */ | 61 */ |
62 | 62 |
63 _o_free_list(ptr) | 63 void |
64 register struct linked_list **ptr; | 64 _o_free_list(struct linked_list **ptr) |
65 { | 65 { |
66 register struct linked_list *item; | 66 register struct linked_list *item; |
67 | 67 |
68 while (*ptr != NULL) | 68 while (*ptr != NULL) |
69 { | 69 { |
76 /* | 76 /* |
77 * o_discard: | 77 * o_discard: |
78 * free up an item and its object(and maybe contents) | 78 * free up an item and its object(and maybe contents) |
79 */ | 79 */ |
80 | 80 |
81 o_discard(item) | 81 void |
82 register struct linked_list *item; | 82 o_discard(struct linked_list *item) |
83 { | 83 { |
84 register struct object *obj; | 84 register struct object *obj; |
85 obj = OBJPTR(item); | 85 obj = OBJPTR(item); |
86 if (obj->contents != NULL) | 86 if (obj->contents != NULL) |
87 o_free_list(obj->contents); | 87 o_free_list(obj->contents); |
93 /* | 93 /* |
94 * t_free_list: | 94 * t_free_list: |
95 * Throw the whole thing list away | 95 * Throw the whole thing list away |
96 */ | 96 */ |
97 | 97 |
98 _t_free_list(ptr) | 98 void |
99 register struct linked_list **ptr; | 99 _t_free_list(struct linked_list **ptr) |
100 { | 100 { |
101 register struct linked_list *item; | 101 register struct linked_list *item; |
102 | 102 |
103 while (*ptr != NULL) | 103 while (*ptr != NULL) |
104 { | 104 { |
111 /* | 111 /* |
112 * t_discard: | 112 * t_discard: |
113 * free up an item and its thing | 113 * free up an item and its thing |
114 */ | 114 */ |
115 | 115 |
116 t_discard(item) | 116 void |
117 struct linked_list *item; | 117 t_discard(struct linked_list *item) |
118 { | 118 { |
119 total -= 2; | 119 total -= 2; |
120 FREE(item->l_data); | 120 FREE(item->l_data); |
121 FREE(item); | 121 FREE(item); |
122 } | 122 } |
124 /* | 124 /* |
125 * destroy_item: | 125 * destroy_item: |
126 * get rid of an item structure -- don't worry about contents | 126 * get rid of an item structure -- don't worry about contents |
127 */ | 127 */ |
128 | 128 |
129 destroy_item(item) | 129 void |
130 register struct linked_list *item; | 130 destroy_item(struct linked_list *item) |
131 { | 131 { |
132 total--; | 132 total--; |
133 FREE(item); | 133 FREE(item); |
134 } | 134 } |
135 | 135 |
137 * new_item | 137 * new_item |
138 * get a new item with a specified size | 138 * get a new item with a specified size |
139 */ | 139 */ |
140 | 140 |
141 struct linked_list * | 141 struct linked_list * |
142 new_item(size) | 142 new_item(int size) |
143 int size; | |
144 { | 143 { |
145 register struct linked_list *item; | 144 register struct linked_list *item; |
146 | 145 |
147 if ((item = (struct linked_list *) new(sizeof *item)) == NULL) | 146 if ((item = (struct linked_list *) new(sizeof *item)) == NULL) |
148 msg("Ran out of memory for header after %d items", total); | 147 msg("Ran out of memory for header after %d items", total); |
156 * creat_item: | 155 * creat_item: |
157 * Create just an item structure -- don't make any contents | 156 * Create just an item structure -- don't make any contents |
158 */ | 157 */ |
159 | 158 |
160 struct linked_list * | 159 struct linked_list * |
161 creat_item() | 160 creat_item(void) |
162 { | 161 { |
163 register struct linked_list *item; | 162 register struct linked_list *item; |
164 | 163 |
165 if ((item = (struct linked_list *) new(sizeof *item)) == NULL) | 164 if ((item = (struct linked_list *) new(sizeof *item)) == NULL) |
166 msg("Ran out of memory for header after %d items", total); | 165 msg("Ran out of memory for header after %d items", total); |
167 item->l_next = item->l_prev = NULL; | 166 item->l_next = item->l_prev = NULL; |
168 return item; | 167 return item; |
169 } | 168 } |
170 | 169 |
171 char * | 170 char * |
172 new(size) | 171 new(int size) |
173 int size; | |
174 { | 172 { |
175 register char *space = ALLOC(size); | 173 register char *space = ALLOC(size); |
176 static char errbuf[LINELEN]; | 174 static char errbuf[LINELEN]; |
177 | 175 |
178 if (space == NULL) { | 176 if (space == NULL) { |