/*
* Copyright 2013 Samsung Electronics Co., Ltd
*
- * Licensed under the Flora License, Version 1.0 (the "License");
+ * Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.tizenopensource.org/license
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
struct dlist *item;
item = malloc(sizeof(*item));
- if (!item)
+ if (!item) {
return NULL;
+ }
item->next = NULL;
item->data = data;
struct dlist *item;
item = malloc(sizeof(*item));
- if (!item)
+ if (!item) {
return NULL;
+ }
item->data = data;
item->prev = item;
item->next = NULL;
} else {
- if (list->prev->next)
+ if (list->prev->next) {
list->prev->next = item;
+ }
item->prev = list->prev;
item->next = list;
struct dlist *dlist_remove(struct dlist *list, struct dlist *l)
{
- if (!list || !l)
+ if (!list || !l) {
return NULL;
+ }
- if (l == list)
+ if (l == list) {
list = l->next;
- else
+ } else {
l->prev->next = l->next;
+ }
- if (l->next)
+ if (l->next) {
l->next->prev = l->prev;
+ }
/*!
* \note
* If the removed entry 'l' has no next element, it is the last element.
*
* If we didn't care about this, the head element(list) can indicates the invalid element.
*/
- else if (list)
+ else if (list) {
list->prev = l->prev;
+ }
free(l);
return list;
void *_data;
dlist_foreach(list, l, _data) {
- if (data == _data)
+ if (data == _data) {
return l;
+ }
}
return NULL;
i = 0;
for (n = l; n; n = n->next) {
- if (i == nth)
+ if (i == nth) {
return n;
+ }
i++;
}