|
|
@@ -14,6 +14,32 @@ static inline void swap_items(sl_list *list, struct sl_list_item *pos, int datai
|
|
|
i->data[size - _i] = tmp;
|
|
|
}
|
|
|
|
|
|
+void *sllist_removeat(sl_list *list, unsigned int _pos)
|
|
|
+{
|
|
|
+ void *result;
|
|
|
+ struct sl_list_item *pos = list->first;
|
|
|
+ struct sl_list_item *lastptr;
|
|
|
+ int i;
|
|
|
+
|
|
|
+ if (_pos >= sllist_count(list))
|
|
|
+ return NULL;
|
|
|
+ for (i =0; i + SL_LIST_BUFLEN < _pos; i += SL_LIST_BUFLEN)
|
|
|
+ pos = pos->next;
|
|
|
+ _pos -= i;
|
|
|
+ if (_pos == sllist_count(list) -1)
|
|
|
+ {
|
|
|
+ list->count--;
|
|
|
+ return pos->data[_pos];
|
|
|
+ }
|
|
|
+ for (lastptr = pos; i + SL_LIST_BUFLEN < sllist_count(list); i += SL_LIST_BUFLEN)
|
|
|
+ lastptr = lastptr->next;
|
|
|
+ i = sllist_count(list) - i;
|
|
|
+ result = pos->data[_pos];
|
|
|
+ pos->data[_pos] = lastptr->data[i];
|
|
|
+ list->count--;
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
int sllist_remove(sl_list *list, int (*fnc)(const void *a, const void *b), void *item)
|
|
|
{
|
|
|
return sllist_n_remove(list, fnc, item, sllist_count(list));
|