[pacman-dev] [PATCH] alpm_list_remove treat NULL needle as "nothing"

Nagy Gabor ngaba at bibl.u-szeged.hu
Wed Jul 16 10:00:53 EDT 2008


From c44fec0058d8a69d29eeb947698bfaf165a6a080 Mon Sep 17 00:00:00 2001
From: Nagy Gabor <ngaba at bibl.u-szeged.hu>
Date: Wed, 16 Jul 2008 15:57:08 +0200
Subject: [PATCH] alpm_list_remove treat NULL needle as "nothing"

So if you want to remove NULL needle from a list, alpm_list_remove will
return with "not found".

Signed-off-by: Nagy Gabor <ngaba at bibl.u-szeged.hu>
---
 lib/libalpm/alpm_list.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c
index 8756740..9889503 100644
--- a/lib/libalpm/alpm_list.c
+++ b/lib/libalpm/alpm_list.c
@@ -302,6 +302,10 @@ alpm_list_t SYMEXPORT *alpm_list_remove(alpm_list_t *haystack, const void *needl
 		*data = NULL;
 	}
 
+	if(needle == NULL) {
+		return(haystack);
+	}
+
 	while(i) {
 		if(i->data == NULL) {
 			continue;
-- 
1.5.6.2





More information about the pacman-dev mailing list