diff mbox

[08/34] ptrlist: let first_ptr_list() use the iterator API

Message ID 20170707134002.49500-9-luc.vanoostenryck@gmail.com (mailing list archive)
State Rejected, archived
Headers show

Commit Message

Luc Van Oostenryck July 7, 2017, 1:39 p.m. UTC
---
 ptrlist.h | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
diff mbox

Patch

diff --git a/ptrlist.h b/ptrlist.h
index ff38538cb..b46967c58 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -86,19 +86,16 @@  static inline void *ptr_cur_entry(const struct ptr_cur *cur)
 #define __PTR_KEEP_TAG(ptr)	(ptr)
 #define PTR_ENTRY(h,i)		__PTR_STRIP_TAG(PTR_ENTRY_NOTAG(h,i))
 
+
 static inline void *first_ptr_list(struct ptr_list *list)
 {
-	struct ptr_list *head = list;
+	struct ptr_cur cur;
 
-	if (!list)
+	if (!ptr_cur_beg(&cur, list))
 		return NULL;
-
-	while (list->nr == 0) {
-		list = list->next;
-		if (list == head)
-			return NULL;
-	}
-	return PTR_ENTRY(list, 0);
+	if (!ptr_cur_next(&cur))
+		return NULL;
+	return __PTR_STRIP_TAG(ptr_cur_entry(&cur));
 }
 
 static inline void *last_ptr_list(struct ptr_list *list)