1 /* PSPP - computes sample statistics.
2 Copyright (C) 2005 Free Software Foundation, Inc.
3 Written by John Darrington <john@darrington.wattle.id.au>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 #include "linked-list.h"
29 /* Return the first element in LL */
31 ll_first (const struct linked_list *ll, struct ll_iterator *li)
37 return ll->head->entry;
40 /* Return the next element in LL iterated by LI */
42 ll_next (const struct linked_list *ll UNUSED, struct ll_iterator *li)
55 /* Create a linked list.
56 Elements will be freed using F and AUX
59 ll_create( ll_free_func *f , void *aux)
61 struct linked_list *ll = xmalloc ( sizeof(struct linked_list) ) ;
71 /* Destroy a linked list */
73 ll_destroy(struct linked_list *ll)
75 struct node *n = ll->head;
79 struct node *nn = n->next;
81 ll->free(n->entry, ll->aux);
90 /* Push a an element ENTRY onto the list LL */
92 ll_push_front(struct linked_list *ll, void *entry)
97 n = xmalloc (sizeof(struct node) );