188 |
188 |
189 static int cx_arl_remove( |
189 static int cx_arl_remove( |
190 struct cx_list_s *list, |
190 struct cx_list_s *list, |
191 size_t index |
191 size_t index |
192 ) { |
192 ) { |
193 return 1; |
193 /* out-of-bounds check */ |
|
194 if (index >= list->size) { |
|
195 return 1; |
|
196 } |
|
197 |
|
198 cx_array_list *arl = (cx_array_list *) list; |
|
199 |
|
200 /* just move the elements starting at index to the left */ |
|
201 int result = cx_array_copy( |
|
202 &arl->data, |
|
203 &list->size, |
|
204 &list->capacity, |
|
205 index, |
|
206 ((char *) arl->data) + (index + 1) * list->itemsize, |
|
207 list->itemsize, |
|
208 list->size - index, |
|
209 &arl->reallocator |
|
210 ); |
|
211 if (result == 0) { |
|
212 /* decrease the size */ |
|
213 list->size--; |
|
214 } |
|
215 return result; |
194 } |
216 } |
195 |
217 |
196 static void *cx_arl_at( |
218 static void *cx_arl_at( |
197 struct cx_list_s const *list, |
219 struct cx_list_s const *list, |
198 size_t index |
220 size_t index |