[pacman-dev] [PATCH] Remove alpm_list_first

Allan McRae allan at archlinux.org
Sun Jul 3 22:16:34 EDT 2011


The only thing this accessor did was remove the const qualifier
given our entire list implementation requires passing around the
head anyway.

Signed-off-by: Allan McRae <allan at archlinux.org>
---
 lib/libalpm/alpm_list.c |   16 ----------------
 lib/libalpm/alpm_list.h |    1 -
 src/pacman/util.c       |    2 +-
 3 files changed, 1 insertions(+), 18 deletions(-)

diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c
index 1976e13..38cefa6 100644
--- a/lib/libalpm/alpm_list.c
+++ b/lib/libalpm/alpm_list.c
@@ -507,22 +507,6 @@ alpm_list_t SYMEXPORT *alpm_list_reverse(alpm_list_t *list)
 /* Accessors */
 
 /**
- * @brief Get the first element of a list.
- *
- * @param list the list
- *
- * @return the first element in the list
- */
-inline alpm_list_t SYMEXPORT *alpm_list_first(const alpm_list_t *list)
-{
-	if(list) {
-		return (alpm_list_t *)list;
-	} else {
-		return NULL;
-	}
-}
-
-/**
  * @brief Return nth element from list (starting from 0).
  *
  * @param list the list
diff --git a/lib/libalpm/alpm_list.h b/lib/libalpm/alpm_list.h
index 27a76d1..824e866 100644
--- a/lib/libalpm/alpm_list.h
+++ b/lib/libalpm/alpm_list.h
@@ -67,7 +67,6 @@ alpm_list_t *alpm_list_copy_data(const alpm_list_t *list, size_t size);
 alpm_list_t *alpm_list_reverse(alpm_list_t *list);
 
 /* item accessors */
-alpm_list_t *alpm_list_first(const alpm_list_t *list);
 alpm_list_t *alpm_list_nth(const alpm_list_t *list, size_t n);
 alpm_list_t *alpm_list_next(const alpm_list_t *list);
 alpm_list_t *alpm_list_previous(const alpm_list_t *list, const alpm_list_t *node);
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 9ced7aa..a24c4ea 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -767,7 +767,7 @@ out:
 	/* cleanup */
 	if(config->verbosepkglists) {
 		/* targets is a list of lists of strings, free inner lists here */
-		for(j = alpm_list_first(targets); j; j = alpm_list_next(j)) {
+		for(j = targets; j; j = alpm_list_next(j)) {
 			lp = alpm_list_getdata(j);
 			FREELIST(lp);
 		}
-- 
1.7.6



More information about the pacman-dev mailing list