+/****f* silcutil/silc_list_pop
+ *
+ * SYNOPSIS
+ *
+ * void *silc_list_pop(SilcList list);
+ *
+ * DESCRIPTION
+ *
+ * Pops the head of the list. Removes the head of the list and returns
+ * the removed head. This will always remove the head of the list even
+ * if silc_list_end was called. Calling silc_list_start is not necessary.
+ * Returns SILC_LIST_END if the list is empty.
+ *
+ ***/
+#define silc_list_pop(x) __silc_list_pop(&(x))
+static inline
+void *__silc_list_pop(SilcList *list)
+{
+ void *head, **p;
+
+ if (!list->head)
+ return NULL;
+
+ head = list->head;
+ p = &list->head;
+ *p = *__silc_list_next(*list, head);
+ if (list->prev_set && *p)
+ *__silc_list_prev(*list, *p) = *__silc_list_prev(*list, head);
+
+ if (list->current == head)
+ list->current = *p;
+ if (head == list->tail)
+ list->tail = NULL;
+
+ list->count--;
+
+ return head;
+}
+
+#endif /* SILCLIST_H */