2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
29 struct dlist *dlist_append(struct dlist *list, void *data)
33 item = malloc(sizeof(*item));
46 item->prev = list->prev;
47 item->prev->next = item;
52 assert(!list->prev->next && "item NEXT");
57 struct dlist *dlist_prepend(struct dlist *list, void *data)
61 item = malloc(sizeof(*item));
70 item->prev = list->prev;
78 struct dlist *dlist_remove(struct dlist *list, struct dlist *l)
88 l->prev->next = l->next;
92 l->next->prev = l->prev;
99 struct dlist *dlist_find_data(struct dlist *list, void *data)
104 dlist_foreach(list, l, _data) {
113 void *dlist_data(struct dlist *l)
115 return l ? l->data : NULL;
118 struct dlist *dlist_next(struct dlist *l)
120 return l ? l->next : NULL;
123 struct dlist *dlist_prev(struct dlist *l)
125 return l ? l->prev : NULL;
128 int dlist_count(struct dlist *l)
135 dlist_foreach(l, n, data) {
142 struct dlist *dlist_nth(struct dlist *l, int nth)
149 dlist_foreach(l, n, data) {