summaryrefslogtreecommitdiffstats
path: root/libdm/datastruct
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2002-12-12 20:55:49 +0000
committerAlasdair Kergon <agk@redhat.com>2002-12-12 20:55:49 +0000
commit4c64ed4ced7dcd3a98a63da1cd3a6f2f1f2d1701 (patch)
tree2c0968a82423acbddbc610bfea5518b212429f91 /libdm/datastruct
parenteb537fa130c9c9fca9c10319b2b955d800ba3742 (diff)
downloadlvm2-4c64ed4ced7dcd3a98a63da1cd3a6f2f1f2d1701.tar.gz
lvm2-4c64ed4ced7dcd3a98a63da1cd3a6f2f1f2d1701.tar.xz
lvm2-4c64ed4ced7dcd3a98a63da1cd3a6f2f1f2d1701.zip
New column-based reporting tools: lvs, pvs & vgs.
Diffstat (limited to 'libdm/datastruct')
-rw-r--r--libdm/datastruct/list.h25
1 files changed, 18 insertions, 7 deletions
diff --git a/libdm/datastruct/list.h b/libdm/datastruct/list.h
index 5f2e14c1..4aeb7b40 100644
--- a/libdm/datastruct/list.h
+++ b/libdm/datastruct/list.h
@@ -13,11 +13,13 @@ struct list {
struct list *n, *p;
};
-static inline void list_init(struct list *head) {
+static inline void list_init(struct list *head)
+{
head->n = head->p = head;
}
-static inline void list_add(struct list *head, struct list *elem) {
+static inline void list_add(struct list *head, struct list *elem)
+{
assert(head->n);
elem->n = head;
@@ -27,7 +29,8 @@ static inline void list_add(struct list *head, struct list *elem) {
head->p = elem;
}
-static inline void list_add_h(struct list *head, struct list *elem) {
+static inline void list_add_h(struct list *head, struct list *elem)
+{
assert(head->n);
elem->n = head->n;
@@ -37,27 +40,35 @@ static inline void list_add_h(struct list *head, struct list *elem) {
head->n = elem;
}
-static inline void list_del(struct list *elem) {
+static inline void list_del(struct list *elem)
+{
elem->n->p = elem->p;
elem->p->n = elem->n;
}
-static inline int list_empty(struct list *head) {
+static inline int list_empty(struct list *head)
+{
return head->n == head;
}
+static inline int list_end(struct list *head, struct list *elem)
+{
+ return elem->n == head;
+}
+
#define list_iterate(v, head) \
for (v = (head)->n; v != head; v = v->n)
#define list_iterate_safe(v, t, head) \
for (v = (head)->n, t = v->n; v != head; v = t, t = v->n)
-static inline int list_size(struct list *head) {
+static inline int list_size(struct list *head)
+{
int s = 0;
struct list *v;
list_iterate(v, head)
- s++;
+ s++;
return s;
}