FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 07-16-2008, 02:00 PM
Nagy Gabor
 
Default alpm_list_remove treat NULL needle as "nothing"

>From c44fec0058d8a69d29eeb947698bfaf165a6a080 Mon Sep 17 00:00:00 2001
From: Nagy Gabor <ngaba@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@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


_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 07-16-2008, 02:03 PM
Nagy Gabor
 
Default alpm_list_remove treat NULL needle as "nothing"

> >From c44fec0058d8a69d29eeb947698bfaf165a6a080 Mon Sep 17 00:00:00
> >2001
> From: Nagy Gabor <ngaba@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@bibl.u-szeged.hu>

After this patch my previous "fix segfault" patch is not needed. But
if you like "safe programming", you will like that patch too.

Bye

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 

Thread Tools




All times are GMT. The time now is 01:13 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org