[PATCH v2 13/17] ptrlist: make {first,last}_ptr_list() out-of-line functions

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

 



These two functions were inline but are already too big, too
complicated to be inlined.

Make them out-of-line functions.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 ptrlist.c | 38 ++++++++++++++++++++++++++++++++++++++
 ptrlist.h | 31 ++-----------------------------
 2 files changed, 40 insertions(+), 29 deletions(-)

diff --git a/ptrlist.c b/ptrlist.c
index c1366f0d0..99771e437 100644
--- a/ptrlist.c
+++ b/ptrlist.c
@@ -36,6 +36,44 @@ int ptr_list_size(struct ptr_list *head)
 	return nr;
 }
 
+///
+// get the first element of a ptrlist
+// @head: the head of the list
+// @return: the first element of the list or ``NULL`` if the list is empty
+void *first_ptr_list(struct ptr_list *head)
+{
+	struct ptr_list *list = head;
+
+	if (!head)
+		return NULL;
+
+	while (list->nr == 0) {
+		list = list->next;
+		if (list == head)
+			return NULL;
+	}
+	return PTR_ENTRY_NOTAG(list, 0);
+}
+
+///
+// get the last element of a ptrlist
+// @head: the head of the list
+// @return: the last element of the list or ``NULL`` if the list is empty
+void *last_ptr_list(struct ptr_list *head)
+{
+	struct ptr_list *list;
+
+	if (!head)
+		return NULL;
+	list = head->prev;
+	while (list->nr == 0) {
+		if (list == head)
+			return NULL;
+		list = list->prev;
+	}
+	return PTR_ENTRY_NOTAG(list, list->nr-1);
+}
+
 ///
 // linearize the entries of a list
 //
diff --git a/ptrlist.h b/ptrlist.h
index 0539fc80a..3693604f0 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -40,6 +40,8 @@ extern void concat_ptr_list(struct ptr_list *a, struct ptr_list **b);
 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);
+extern void *first_ptr_list(struct ptr_list *);
+extern void *last_ptr_list(struct ptr_list *);
 
 /*
  * Hey, who said that you can't do overloading in C?
@@ -67,35 +69,6 @@ extern int linearize_ptr_list(struct ptr_list *, void **, int);
 #define PTR_ENTRY_NOTAG(h,i)	((h)->list[i])
 #define PTR_ENTRY_UNTAG(h,i)	PTR_UNTAG((h)->list[i])
 
-static inline void *first_ptr_list(struct ptr_list *list)
-{
-	struct ptr_list *head = list;
-
-	if (!list)
-		return NULL;
-
-	while (list->nr == 0) {
-		list = list->next;
-		if (list == head)
-			return NULL;
-	}
-	return PTR_ENTRY_NOTAG(list, 0);
-}
-
-static inline void *last_ptr_list(struct ptr_list *list)
-{
-	struct ptr_list *head = list;
-
-	if (!list)
-		return NULL;
-	list = list->prev;
-	while (list->nr == 0) {
-		if (list == head)
-			return NULL;
-		list = list->prev;
-	}
-	return PTR_ENTRY_NOTAG(list, list->nr-1);
-}
 
 #define PTR_NEXT(ptr, __head, __list, __nr, PTR_ENTRY)			\
 	do {								\
-- 
2.17.1

--
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