[PATCH 28/34] ptrlist: let undo_ptr_list_last() use the iterator API

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

 



---
 ptrlist.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/ptrlist.c b/ptrlist.c
index b4fb3fd6e..bae5512f3 100644
--- a/ptrlist.c
+++ b/ptrlist.c
@@ -192,22 +192,17 @@ out:
 /* This removes the last entry, but doesn't pack the ptr list */
 void * undo_ptr_list_last(struct ptr_list **head)
 {
-	struct ptr_list *last, *first = *head;
+	struct ptr_cur cur;
+	void *ptr;
 
-	if (!first)
+	if (!ptr_cur_end(&cur, *head) || !ptr_cur_prev(&cur))
 		return NULL;
-	last = first;
-	do {
-		last = last->prev;
-		if (last->nr) {
-			void *ptr;
-			int nr = --last->nr;
-			ptr = last->list[nr];
-			last->list[nr] = (void *)0xf1f1f1f1;
-			return ptr;
-		}
-	} while (last != first);
-	return NULL;
+
+	ptr = cur.l->list[cur.n];
+	cur.l->list[cur.n--] = (void *)0xf1f1f1f1;
+	cur.l->nr--;
+
+	return ptr;
 }
 
 void * delete_ptr_list_last(struct ptr_list **head)
-- 
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