#include #include "sllist.h" static inline void free_nexts(struct sl_list_item* i) { struct sl_list_item *tmp = i->next; while (i->next) { tmp = i->next; i->next = tmp->next; free(tmp); } } void *sllist_popback(sl_list *list) { void *data; struct sl_list_item *i = list->first; unsigned int pos = sllist_count(list) -1; while (pos > SL_LIST_BUFLEN) { i = i->next; pos -= SL_LIST_BUFLEN; } data = i->data[pos]; if (pos == 0 && i->next) free_nexts(i); list->count--; return data; }