Avoid adding elements twice
This commit is contained in:
parent
e53b93384a
commit
a1f69138d1
1 changed files with 4 additions and 1 deletions
|
@ -43,7 +43,7 @@
|
||||||
*
|
*
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
*
|
*
|
||||||
* $Id: list.c,v 1.3 2010/03/22 11:29:58 fros4943 Exp $
|
* $Id: list.c,v 1.4 2010/04/30 07:18:24 adamdunkels Exp $
|
||||||
*/
|
*/
|
||||||
#include "lib/list.h"
|
#include "lib/list.h"
|
||||||
|
|
||||||
|
@ -166,6 +166,9 @@ list_push(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 = *list;
|
((struct list *)item)->next = *list;
|
||||||
*list = item;
|
*list = item;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue