2 * Copyright Geoff Levand <geoff@infradead.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #if defined(HAVE_CONFIG_H)
27 #include <list/list.h>
33 struct list_item list;
41 for (i = 0; i < 5; i++) {
42 struct item *item = malloc(sizeof(struct item));
46 list_add_tail(&tester, &item->list);
50 fprintf(stderr, "-- list_for_each_entry --\n");
51 list_for_each_entry(&tester, item, list) {
52 fprintf(stderr, "%d: %d: %p -> %p\n", i++, item->value, item, item->list.next);
56 fprintf(stderr, "-- list_for_each_entry_safe --\n");
57 list_for_each_entry_safe(&tester, item, tmp, list) {
58 fprintf(stderr, "pos: %d: %d: %p -> %p\n", i++, item->value, item, item->list.next);
59 fprintf(stderr, "tmp: %p -> %p\n", tmp, (tmp ? tmp->list.next : NULL));
60 list_remove(&item->list);
64 fprintf(stderr, "-- list_for_each_entry --\n");
65 list_for_each_entry(&tester, item, list) {
66 fprintf(stderr, "%d: %d: %p -> %p\n", i++, item->value, item, item->list.next);
69 fprintf(stderr, "-- done --\n");