changed list_pop to return removed element

This commit is contained in:
joxe 2008-12-16 09:59:42 +00:00
parent 558244b488
commit d2dc732435
2 changed files with 9 additions and 7 deletions

View File

@ -43,7 +43,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $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;
}
/*---------------------------------------------------------------------------*/
/**

View File

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $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;