From d2dc7324350cad861c84210e3cfb6d50d0637b15 Mon Sep 17 00:00:00 2001 From: joxe Date: Tue, 16 Dec 2008 09:59:42 +0000 Subject: [PATCH] changed list_pop to return removed element --- core/lib/list.c | 10 ++++++---- platform/netsim/ether.c | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/core/lib/list.c b/core/lib/list.c index 96272e36c..3cf43a27f 100644 --- a/core/lib/list.c +++ b/core/lib/list.c @@ -43,7 +43,7 @@ * * Author: Adam Dunkels * - * $Id: list.c,v 1.1 2006/06/17 22:41:18 adamdunkels Exp $ + * $Id: list.c,v 1.2 2008/12/16 09:59:42 joxe Exp $ */ #include "lib/list.h" @@ -202,20 +202,22 @@ list_chop(list_t list) * Remove the first object on a list. * * This function removes the first object on the list and returns a - * pointer to the list. + * pointer to it. * * \param list The list. - * \return The new head of the list. + * \return Pointer to the removed element of list. */ /*---------------------------------------------------------------------------*/ void * list_pop(list_t list) { + struct list *l; + l = *list; if(*list != NULL) { *list = ((struct list *)*list)->next; } - return *list; + return l; } /*---------------------------------------------------------------------------*/ /** diff --git a/platform/netsim/ether.c b/platform/netsim/ether.c index 034f1bdd7..3c506e96b 100644 --- a/platform/netsim/ether.c +++ b/platform/netsim/ether.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: ether.c,v 1.13 2008/05/14 19:22:58 adamdunkels Exp $ + * $Id: ether.c,v 1.14 2008/12/16 09:59:42 joxe Exp $ */ /** * \file @@ -499,8 +499,8 @@ ether_tick(void) } /* Remove all packets from the active packets list. */ - for(p = list_head(active_packets); p != NULL; p = list_pop(active_packets)) { - memb_free(&packets, (void *)p); + while((p = list_pop(active_packets)) != NULL) { + memb_free(&packets, (void *) p); } ++timer;