2 * This file is part of buxton.
4 * Copyright (C) 2014 Intel Corporation
6 * buxton is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1
9 * of the License, or (at your option) any later version.
21 #include "buxtonlist.h"
23 bool buxton_list_append(BuxtonList **list, void *data)
25 BuxtonList *head = *list;
27 BuxtonList *parent = NULL;
28 BuxtonList *next = NULL;
31 /* New head generation */
32 head = calloc(1, sizeof(BuxtonList));
42 next = calloc(1, sizeof(BuxtonList));
60 bool buxton_list_prepend(BuxtonList **list, void *data)
62 BuxtonList *head = *list;
63 BuxtonList *prev = NULL;
66 /* New head generation */
67 head = calloc(1, sizeof(BuxtonList));
77 prev = calloc(1, sizeof(BuxtonList));
81 prev->size = head->size+1;
84 prev->tail = head->tail;
87 /* Previous item is now the head */
94 bool buxton_list_remove(BuxtonList **list, void *data, bool do_free)
96 BuxtonList *head = *list;
97 BuxtonList *current = head;
98 BuxtonList *prev = head;
100 /* Determine the node inside the list */
101 while ((current != NULL) && (current->data != data)) {
103 current = current->next;
110 /* Data on the head (head removal)*/
111 if (current == head) {
113 head->next->size = head->size -1;
119 prev->next = current->next;
123 /* Update tail pointer */
124 if (head && head->tail == current) {
126 head->tail->next = NULL;
140 * Editor modelines - http://www.wireshark.org/tools/modelines.html
145 * indent-tabs-mode: t
148 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
149 * :indentSize=8:tabSize=8:noTabs=false: