projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
K&R style braces
[tinc]
/
lib
/
list.c
diff --git
a/lib/list.c
b/lib/list.c
index
0b516c8
..
c5dccb7
100644
(file)
--- a/
lib/list.c
+++ b/
lib/list.c
@@
-1,7
+1,7
@@
/*
list.c -- functions to deal with double linked lists
/*
list.c -- functions to deal with double linked lists
- Copyright (C) 2000-200
3 Ivo Timmermans <ivo@o2w.nl>
- 2000-200
3 Guus Sliepen <guus@sliepen.eu
.org>
+ Copyright (C) 2000-200
5 Ivo Timmermans
+ 2000-200
6 Guus Sliepen <guus@tinc-vpn
.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-17,22
+17,17
@@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id
: list.c,v 1.1.2.15 2003/07/12 17:48:38 guus Exp
$
+ $Id$
*/
*/
-#include "config.h"
-
-#include <stdlib.h>
-
-#include <xalloc.h>
-#include <system.h>
+#include "system.h"
#include "list.h"
#include "list.h"
+#include "xalloc.h"
/* (De)constructors */
/* (De)constructors */
-list_t *list_alloc(list_action_t delete)
-{
+list_t *list_alloc(list_action_t delete) {
list_t *list;
list = xmalloc_and_zero(sizeof(list_t));
list_t *list;
list = xmalloc_and_zero(sizeof(list_t));
@@
-41,18
+36,15
@@
list_t *list_alloc(list_action_t delete)
return list;
}
return list;
}
-void list_free(list_t *list)
-{
+void list_free(list_t *list) {
free(list);
}
free(list);
}
-list_node_t *list_alloc_node(void)
-{
- return (list_node_t *)xmalloc_and_zero(sizeof(list_node_t));
+list_node_t *list_alloc_node(void) {
+ return xmalloc_and_zero(sizeof(list_node_t));
}
}
-void list_free_node(list_t *list, list_node_t *node)
-{
+void list_free_node(list_t *list, list_node_t *node) {
if(node->data && list->delete)
list->delete(node->data);
if(node->data && list->delete)
list->delete(node->data);
@@
-61,8
+53,7
@@
void list_free_node(list_t *list, list_node_t *node)
/* Insertion and deletion */
/* Insertion and deletion */
-list_node_t *list_insert_head(list_t *list, void *data)
-{
+list_node_t *list_insert_head(list_t *list, void *data) {
list_node_t *node;
node = list_alloc_node();
list_node_t *node;
node = list_alloc_node();
@@
-82,8
+73,7
@@
list_node_t *list_insert_head(list_t *list, void *data)
return node;
}
return node;
}
-list_node_t *list_insert_tail(list_t *list, void *data)
-{
+list_node_t *list_insert_tail(list_t *list, void *data) {
list_node_t *node;
node = list_alloc_node();
list_node_t *node;
node = list_alloc_node();
@@
-103,8
+93,7
@@
list_node_t *list_insert_tail(list_t *list, void *data)
return node;
}
return node;
}
-void list_unlink_node(list_t *list, list_node_t *node)
-{
+void list_unlink_node(list_t *list, list_node_t *node) {
if(node->prev)
node->prev->next = node->next;
else
if(node->prev)
node->prev->next = node->next;
else
@@
-118,34
+107,29
@@
void list_unlink_node(list_t *list, list_node_t *node)
list->count--;
}
list->count--;
}
-void list_delete_node(list_t *list, list_node_t *node)
-{
+void list_delete_node(list_t *list, list_node_t *node) {
list_unlink_node(list, node);
list_free_node(list, node);
}
list_unlink_node(list, node);
list_free_node(list, node);
}
-void list_delete_head(list_t *list)
-{
+void list_delete_head(list_t *list) {
list_delete_node(list, list->head);
}
list_delete_node(list, list->head);
}
-void list_delete_tail(list_t *list)
-{
+void list_delete_tail(list_t *list) {
list_delete_node(list, list->tail);
}
/* Head/tail lookup */
list_delete_node(list, list->tail);
}
/* Head/tail lookup */
-void *list_get_head(list_t *list)
-{
+void *list_get_head(list_t *list) {
if(list->head)
return list->head->data;
else
return NULL;
}
if(list->head)
return list->head->data;
else
return NULL;
}
-void *list_get_tail(list_t *list)
-{
+void *list_get_tail(list_t *list) {
if(list->tail)
return list->tail->data;
else
if(list->tail)
return list->tail->data;
else
@@
-154,8
+138,7
@@
void *list_get_tail(list_t *list)
/* Fast list deletion */
/* Fast list deletion */
-void list_delete_list(list_t *list)
-{
+void list_delete_list(list_t *list) {
list_node_t *node, *next;
for(node = list->head; node; node = next) {
list_node_t *node, *next;
for(node = list->head; node; node = next) {
@@
-168,8
+151,7
@@
void list_delete_list(list_t *list)
/* Traversing */
/* Traversing */
-void list_foreach_node(list_t *list, list_action_node_t action)
-{
+void list_foreach_node(list_t *list, list_action_node_t action) {
list_node_t *node, *next;
for(node = list->head; node; node = next) {
list_node_t *node, *next;
for(node = list->head; node; node = next) {
@@
-178,8
+160,7
@@
void list_foreach_node(list_t *list, list_action_node_t action)
}
}
}
}
-void list_foreach(list_t *list, list_action_t action)
-{
+void list_foreach(list_t *list, list_action_t action) {
list_node_t *node, *next;
for(node = list->head; node; node = next) {
list_node_t *node, *next;
for(node = list->head; node; node = next) {