make sure not to add an already existing list element, as it breaks the list iteration functions
This commit is contained in:
parent
7e022b42df
commit
3394a3ef23
|
@ -43,7 +43,7 @@
|
||||||
*
|
*
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
*
|
*
|
||||||
* $Id: list.c,v 1.2 2008/12/16 09:59:42 joxe Exp $
|
* $Id: list.c,v 1.3 2010/03/22 11:29:58 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
#include "lib/list.h"
|
#include "lib/list.h"
|
||||||
|
|
||||||
|
@ -144,6 +144,9 @@ list_add(list_t list, void *item)
|
||||||
{
|
{
|
||||||
struct list *l;
|
struct list *l;
|
||||||
|
|
||||||
|
/* Make sure not to add the same element twice */
|
||||||
|
list_remove(list, item);
|
||||||
|
|
||||||
((struct list *)item)->next = NULL;
|
((struct list *)item)->next = NULL;
|
||||||
|
|
||||||
l = list_tail(list);
|
l = list_tail(list);
|
||||||
|
|
Loading…
Reference in a new issue