diff mbox

[10/34] ptrlist: let lastst_ptr_list() use the iterator API

Message ID 20170707134002.49500-11-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 | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
diff mbox

Patch

diff --git a/ptrlist.h b/ptrlist.h
index 883cca952..f856a54eb 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -102,17 +102,13 @@  static inline void *first_ptr_list(struct ptr_list *list)
 
 static inline void *last_ptr_list(struct ptr_list *list)
 {
-	struct ptr_list *head = list;
+	struct ptr_cur cur;
 
-	if (!list)
+	if (!ptr_cur_end(&cur, list))
+		return NULL;
+	if (!ptr_cur_prev(&cur))
 		return NULL;
-	list = list->prev;
-	while (list->nr == 0) {
-		if (list == head)
-			return NULL;
-		list = list->prev;
-	}
-	return PTR_ENTRY(list, list->nr-1);
+	return __PTR_STRIP_TAG(ptr_cur_entry(&cur));
 }
 
 #define PTR_DEREF(__head, idx, PTR_ENTRY) ({						\