[PATCH 07/34] ptrlist: add forward iterator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 ptrlist.c | 27 +++++++++++++++++++++++++++
 ptrlist.h |  3 +++
 2 files changed, 30 insertions(+)

diff --git a/ptrlist.c b/ptrlist.c
index 5dc1117c5..5798aec43 100644
--- a/ptrlist.c
+++ b/ptrlist.c
@@ -246,3 +246,30 @@ void __free_ptr_list(struct ptr_list **listp)
 
 	*listp = NULL;
 }
+
+
+int ptr_cur_next(struct ptr_cur *cur)
+{
+	do {
+		struct ptr_list *curl = cur->l;
+
+		if (++cur->n < curl->nr)
+			return 1;
+
+		cur->l = curl->next;
+		cur->n = -1;
+	} while (cur->l != cur->h);
+
+	return 0;
+}
+
+int ptr_cur_beg(struct ptr_cur *cur, struct ptr_list *head)
+{
+	if (!head)
+		return 0;
+
+	cur->h = head;
+	cur->l = head;
+	cur->n = -1;
+	return 1;
+}
diff --git a/ptrlist.h b/ptrlist.h
index d271f9e04..ff38538cb 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -51,6 +51,9 @@ extern void __free_ptr_list(struct ptr_list **);
 extern int ptr_list_size(struct ptr_list *);
 extern int linearize_ptr_list(struct ptr_list *, void **, int);
 
+int ptr_cur_beg(struct ptr_cur *cur, struct ptr_list *head);
+int ptr_cur_next(struct ptr_cur *cur);
+
 /*
  * Hey, who said that you can't do overloading in C?
  *
-- 
2.13.0

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux