2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (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://www.tizenopensource.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));
45 item->prev = list->prev;
46 item->prev->next = item;
51 assert(!list->prev->next && "item NEXT");
56 struct dlist *dlist_prepend(struct dlist *list, void *data)
60 item = malloc(sizeof(*item));
68 item->prev = list->prev;
76 struct dlist *dlist_remove(struct dlist *list, struct dlist *l)
85 l->prev->next = l->next;
89 l->next->prev = l->prev;
95 struct dlist *dlist_find_data(struct dlist *list, void *data)
100 dlist_foreach(list, l, _data) {
108 void *dlist_data(struct dlist *l)
110 return l ? l->data : NULL;
113 struct dlist *dlist_next(struct dlist *l)
115 return l ? l->next : NULL;
118 struct dlist *dlist_prev(struct dlist *l)
120 return l ? l->prev : NULL;
123 int dlist_count(struct dlist *l)
130 dlist_foreach(l, n, data) {
137 struct dlist *dlist_nth(struct dlist *l, int nth)
144 dlist_foreach(l, n, data) {