Version 1.01.05 -
=============================
+ Resync list.h with LVM2.
Remember increased buffer size and use for subsequent calls.
On 'buffer full' condition, double buffer size and repeat ioctl.
Fix termination of getopt_long() option array.
return elem->n == head;
}
+/*
+ * Return first element of the list or NULL if empty
+ */
+static inline struct list *list_first(struct list *head)
+{
+ return (list_empty(head) ? NULL : head->n);
+}
+
+/*
+ * Return last element of the list or NULL if empty
+ */
+static inline struct list *list_last(struct list *head)
+{
+ return (list_empty(head) ? NULL : head->p);
+}
+
/*
* Return the previous element of the list, or NULL if we've reached the start.
*/
*/
#define list_iterate_items(v, head) list_iterate_items_gen(v, (head), list)
+/*
+ * Walk a list backwards, setting 'v' in turn to the containing structure
+ * of each item.
+ * The containing structure should be the same type as 'v'.
+ * The 'struct list' variable within the containing structure is 'field'.
+ */
+#define list_iterate_back_items_gen(v, head, field) \
+ for (v = list_struct_base((head)->p, typeof(*v), field); \
+ &v->field != (head); \
+ v = list_struct_base(v->field.p, typeof(*v), field))
+
+/*
+ * Walk a list backwards, setting 'v' in turn to the containing structure
+ * of each item.
+ * The containing structure should be the same type as 'v'.
+ * The list should be 'struct list list' within the containing structure.
+ */
+#define list_iterate_back_items(v, head) list_iterate_back_items_gen(v, (head), list)
+
/*
* Return the number of elements in a list by walking it.
*/