Remove redundant spaces.
This commit is contained in:
parent
9f38e39463
commit
6f9f6779e6
35 changed files with 270 additions and 255 deletions
|
@ -29,7 +29,7 @@
|
|||
library for inclusion into tinc (http://tinc.nl.linux.org/) by
|
||||
Guus Sliepen <guus@sliepen.eu.org>.
|
||||
|
||||
$Id: avl_tree.c,v 1.1.2.10 2002/09/09 21:49:16 guus Exp $
|
||||
$Id: avl_tree.c,v 1.1.2.11 2002/09/09 22:32:24 guus Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -89,7 +89,7 @@ int lg(unsigned int u)
|
|||
|
||||
/* Internal helper functions */
|
||||
|
||||
int avl_check_balance(avl_node_t * node)
|
||||
int avl_check_balance(avl_node_t *node)
|
||||
{
|
||||
#ifdef AVL_DEPTH
|
||||
int d;
|
||||
|
@ -117,7 +117,7 @@ int avl_check_balance(avl_node_t * node)
|
|||
#endif
|
||||
}
|
||||
|
||||
void avl_rebalance(avl_tree_t * tree, avl_node_t * node)
|
||||
void avl_rebalance(avl_tree_t *tree, avl_node_t *node)
|
||||
{
|
||||
avl_node_t *child;
|
||||
avl_node_t *gchild;
|
||||
|
@ -272,7 +272,7 @@ avl_tree_t *avl_alloc_tree(avl_compare_t compare, avl_action_t delete)
|
|||
return tree;
|
||||
}
|
||||
|
||||
void avl_free_tree(avl_tree_t * tree)
|
||||
void avl_free_tree(avl_tree_t *tree)
|
||||
{
|
||||
free(tree);
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ avl_node_t *avl_alloc_node(void)
|
|||
return (avl_node_t *)xmalloc_and_zero(sizeof(avl_node_t));
|
||||
}
|
||||
|
||||
void avl_free_node(avl_tree_t * tree, avl_node_t * node)
|
||||
void avl_free_node(avl_tree_t *tree, avl_node_t *node)
|
||||
{
|
||||
if(node->data && tree->delete)
|
||||
tree->delete(node->data);
|
||||
|
@ -292,7 +292,7 @@ void avl_free_node(avl_tree_t * tree, avl_node_t * node)
|
|||
|
||||
/* Searching */
|
||||
|
||||
void *avl_search(const avl_tree_t * tree, const void *data)
|
||||
void *avl_search(const avl_tree_t *tree, const void *data)
|
||||
{
|
||||
avl_node_t *node;
|
||||
|
||||
|
@ -301,7 +301,7 @@ void *avl_search(const avl_tree_t * tree, const void *data)
|
|||
return node ? node->data : NULL;
|
||||
}
|
||||
|
||||
void *avl_search_closest(const avl_tree_t * tree, const void *data, int *result)
|
||||
void *avl_search_closest(const avl_tree_t *tree, const void *data, int *result)
|
||||
{
|
||||
avl_node_t *node;
|
||||
|
||||
|
@ -310,7 +310,7 @@ void *avl_search_closest(const avl_tree_t * tree, const void *data, int *result)
|
|||
return node ? node->data : NULL;
|
||||
}
|
||||
|
||||
void *avl_search_closest_smaller(const avl_tree_t * tree, const void *data)
|
||||
void *avl_search_closest_smaller(const avl_tree_t *tree, const void *data)
|
||||
{
|
||||
avl_node_t *node;
|
||||
|
||||
|
@ -319,7 +319,7 @@ void *avl_search_closest_smaller(const avl_tree_t * tree, const void *data)
|
|||
return node ? node->data : NULL;
|
||||
}
|
||||
|
||||
void *avl_search_closest_greater(const avl_tree_t * tree, const void *data)
|
||||
void *avl_search_closest_greater(const avl_tree_t *tree, const void *data)
|
||||
{
|
||||
avl_node_t *node;
|
||||
|
||||
|
@ -328,7 +328,7 @@ void *avl_search_closest_greater(const avl_tree_t * tree, const void *data)
|
|||
return node ? node->data : NULL;
|
||||
}
|
||||
|
||||
avl_node_t *avl_search_node(const avl_tree_t * tree, const void *data)
|
||||
avl_node_t *avl_search_node(const avl_tree_t *tree, const void *data)
|
||||
{
|
||||
avl_node_t *node;
|
||||
int result;
|
||||
|
@ -338,7 +338,7 @@ avl_node_t *avl_search_node(const avl_tree_t * tree, const void *data)
|
|||
return result ? NULL : node;
|
||||
}
|
||||
|
||||
avl_node_t *avl_search_closest_node(const avl_tree_t * tree, const void *data,
|
||||
avl_node_t *avl_search_closest_node(const avl_tree_t *tree, const void *data,
|
||||
int *result)
|
||||
{
|
||||
avl_node_t *node;
|
||||
|
@ -381,7 +381,7 @@ avl_node_t *avl_search_closest_node(const avl_tree_t * tree, const void *data,
|
|||
return node;
|
||||
}
|
||||
|
||||
avl_node_t *avl_search_closest_smaller_node(const avl_tree_t * tree,
|
||||
avl_node_t *avl_search_closest_smaller_node(const avl_tree_t *tree,
|
||||
const void *data)
|
||||
{
|
||||
avl_node_t *node;
|
||||
|
@ -395,7 +395,7 @@ avl_node_t *avl_search_closest_smaller_node(const avl_tree_t * tree,
|
|||
return node;
|
||||
}
|
||||
|
||||
avl_node_t *avl_search_closest_greater_node(const avl_tree_t * tree,
|
||||
avl_node_t *avl_search_closest_greater_node(const avl_tree_t *tree,
|
||||
const void *data)
|
||||
{
|
||||
avl_node_t *node;
|
||||
|
@ -411,7 +411,7 @@ avl_node_t *avl_search_closest_greater_node(const avl_tree_t * tree,
|
|||
|
||||
/* Insertion and deletion */
|
||||
|
||||
avl_node_t *avl_insert(avl_tree_t * tree, void *data)
|
||||
avl_node_t *avl_insert(avl_tree_t *tree, void *data)
|
||||
{
|
||||
avl_node_t *closest, *new;
|
||||
int result;
|
||||
|
@ -451,7 +451,7 @@ avl_node_t *avl_insert(avl_tree_t * tree, void *data)
|
|||
return new;
|
||||
}
|
||||
|
||||
avl_node_t *avl_insert_node(avl_tree_t * tree, avl_node_t * node)
|
||||
avl_node_t *avl_insert_node(avl_tree_t *tree, avl_node_t *node)
|
||||
{
|
||||
avl_node_t *closest;
|
||||
int result;
|
||||
|
@ -485,14 +485,14 @@ avl_node_t *avl_insert_node(avl_tree_t * tree, avl_node_t * node)
|
|||
return node;
|
||||
}
|
||||
|
||||
void avl_insert_top(avl_tree_t * tree, avl_node_t * node)
|
||||
void avl_insert_top(avl_tree_t *tree, avl_node_t *node)
|
||||
{
|
||||
node->prev = node->next = node->parent = NULL;
|
||||
tree->head = tree->tail = tree->root = node;
|
||||
}
|
||||
|
||||
void avl_insert_before(avl_tree_t * tree, avl_node_t * before,
|
||||
avl_node_t * node)
|
||||
void avl_insert_before(avl_tree_t *tree, avl_node_t *before,
|
||||
avl_node_t *node)
|
||||
{
|
||||
if(!before)
|
||||
return tree->tail ? avl_insert_after(tree, tree->tail, node) : avl_insert_top(tree, node);
|
||||
|
@ -515,7 +515,7 @@ void avl_insert_before(avl_tree_t * tree, avl_node_t * before,
|
|||
avl_rebalance(tree, before->parent);
|
||||
}
|
||||
|
||||
void avl_insert_after(avl_tree_t * tree, avl_node_t * after, avl_node_t * node)
|
||||
void avl_insert_after(avl_tree_t *tree, avl_node_t *after, avl_node_t *node)
|
||||
{
|
||||
if(!after)
|
||||
return tree->head ? avl_insert_before(tree, tree->head,
|
||||
|
@ -540,7 +540,7 @@ void avl_insert_after(avl_tree_t * tree, avl_node_t * after, avl_node_t * node)
|
|||
avl_rebalance(tree, after->parent);
|
||||
}
|
||||
|
||||
avl_node_t *avl_unlink(avl_tree_t * tree, void *data)
|
||||
avl_node_t *avl_unlink(avl_tree_t *tree, void *data)
|
||||
{
|
||||
avl_node_t *node;
|
||||
|
||||
|
@ -552,7 +552,7 @@ avl_node_t *avl_unlink(avl_tree_t * tree, void *data)
|
|||
return node;
|
||||
}
|
||||
|
||||
void avl_unlink_node(avl_tree_t * tree, avl_node_t * node)
|
||||
void avl_unlink_node(avl_tree_t *tree, avl_node_t *node)
|
||||
{
|
||||
avl_node_t *parent;
|
||||
avl_node_t **superparent;
|
||||
|
@ -621,13 +621,13 @@ void avl_unlink_node(avl_tree_t * tree, avl_node_t * node)
|
|||
#endif
|
||||
}
|
||||
|
||||
void avl_delete_node(avl_tree_t * tree, avl_node_t * node)
|
||||
void avl_delete_node(avl_tree_t *tree, avl_node_t *node)
|
||||
{
|
||||
avl_unlink_node(tree, node);
|
||||
avl_free_node(tree, node);
|
||||
}
|
||||
|
||||
void avl_delete(avl_tree_t * tree, void *data)
|
||||
void avl_delete(avl_tree_t *tree, void *data)
|
||||
{
|
||||
avl_node_t *node;
|
||||
|
||||
|
@ -639,7 +639,7 @@ void avl_delete(avl_tree_t * tree, void *data)
|
|||
|
||||
/* Fast tree cleanup */
|
||||
|
||||
void avl_delete_tree(avl_tree_t * tree)
|
||||
void avl_delete_tree(avl_tree_t *tree)
|
||||
{
|
||||
avl_node_t *node, *next;
|
||||
|
||||
|
@ -653,7 +653,7 @@ void avl_delete_tree(avl_tree_t * tree)
|
|||
|
||||
/* Tree walking */
|
||||
|
||||
void avl_foreach(avl_tree_t * tree, avl_action_t action)
|
||||
void avl_foreach(avl_tree_t *tree, avl_action_t action)
|
||||
{
|
||||
avl_node_t *node, *next;
|
||||
|
||||
|
@ -663,7 +663,7 @@ void avl_foreach(avl_tree_t * tree, avl_action_t action)
|
|||
}
|
||||
}
|
||||
|
||||
void avl_foreach_node(avl_tree_t * tree, avl_action_t action)
|
||||
void avl_foreach_node(avl_tree_t *tree, avl_action_t action)
|
||||
{
|
||||
avl_node_t *node, *next;
|
||||
|
||||
|
@ -676,12 +676,12 @@ void avl_foreach_node(avl_tree_t * tree, avl_action_t action)
|
|||
/* Indexing */
|
||||
|
||||
#ifdef AVL_COUNT
|
||||
unsigned int avl_count(avl_tree_t * tree)
|
||||
unsigned int avl_count(avl_tree_t *tree)
|
||||
{
|
||||
return AVL_NODE_COUNT(tree->root);
|
||||
}
|
||||
|
||||
avl_node_t *avl_get_node(const avl_tree_t * tree, unsigned int index)
|
||||
avl_node_t *avl_get_node(const avl_tree_t *tree, unsigned int index)
|
||||
{
|
||||
avl_node_t *node;
|
||||
unsigned int c;
|
||||
|
@ -704,7 +704,7 @@ avl_node_t *avl_get_node(const avl_tree_t * tree, unsigned int index)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
unsigned int avl_index(const avl_node_t * node)
|
||||
unsigned int avl_index(const avl_node_t *node)
|
||||
{
|
||||
avl_node_t *next;
|
||||
unsigned int index;
|
||||
|
@ -721,7 +721,7 @@ unsigned int avl_index(const avl_node_t * node)
|
|||
}
|
||||
#endif
|
||||
#ifdef AVL_DEPTH
|
||||
unsigned int avl_depth(avl_tree_t * tree)
|
||||
unsigned int avl_depth(avl_tree_t *tree)
|
||||
{
|
||||
return AVL_NODE_DEPTH(tree->root);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
library for inclusion into tinc (http://tinc.nl.linux.org/) by
|
||||
Guus Sliepen <guus@sliepen.eu.org>.
|
||||
|
||||
$Id: avl_tree.h,v 1.1.2.6 2002/09/09 21:49:16 guus Exp $
|
||||
$Id: avl_tree.h,v 1.1.2.7 2002/09/09 22:32:27 guus Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
@ -68,9 +68,9 @@ typedef struct avl_node_t {
|
|||
|
||||
} avl_node_t;
|
||||
|
||||
typedef int (*avl_compare_t) (const void *, const void *);
|
||||
typedef void (*avl_action_t) (const void *);
|
||||
typedef void (*avl_action_node_t) (const avl_node_t *);
|
||||
typedef int (*avl_compare_t)(const void *, const void *);
|
||||
typedef void (*avl_action_t)(const void *);
|
||||
typedef void (*avl_action_node_t)(const avl_node_t *);
|
||||
|
||||
typedef struct avl_tree_t {
|
||||
|
||||
|
@ -94,7 +94,7 @@ extern avl_tree_t *avl_alloc_tree(avl_compare_t, avl_action_t);
|
|||
extern void avl_free_tree(avl_tree_t *);
|
||||
|
||||
extern avl_node_t *avl_alloc_node(void);
|
||||
extern void avl_free_node(avl_tree_t * tree, avl_node_t *);
|
||||
extern void avl_free_node(avl_tree_t *tree, avl_node_t *);
|
||||
|
||||
/* Insertion and deletion */
|
||||
|
||||
|
@ -106,7 +106,7 @@ extern void avl_insert_before(avl_tree_t *, avl_node_t *, avl_node_t *);
|
|||
extern void avl_insert_after(avl_tree_t *, avl_node_t *, avl_node_t *);
|
||||
|
||||
extern avl_node_t *avl_unlink(avl_tree_t *, void *);
|
||||
extern void avl_unlink_node(avl_tree_t * tree, avl_node_t *);
|
||||
extern void avl_unlink_node(avl_tree_t *tree, avl_node_t *);
|
||||
extern void avl_delete(avl_tree_t *, void *);
|
||||
extern void avl_delete_node(avl_tree_t *, avl_node_t *);
|
||||
|
||||
|
|
28
lib/list.c
28
lib/list.c
|
@ -17,7 +17,7 @@
|
|||
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.12 2002/09/09 21:49:16 guus Exp $
|
||||
$Id: list.c,v 1.1.2.13 2002/09/09 22:32:27 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -41,7 +41,7 @@ list_t *list_alloc(list_action_t delete)
|
|||
return list;
|
||||
}
|
||||
|
||||
void list_free(list_t * list)
|
||||
void list_free(list_t *list)
|
||||
{
|
||||
free(list);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ list_node_t *list_alloc_node(void)
|
|||
return (list_node_t *)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);
|
||||
|
@ -61,7 +61,7 @@ void list_free_node(list_t * list, list_node_t * node)
|
|||
|
||||
/* 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;
|
||||
|
||||
|
@ -82,7 +82,7 @@ list_node_t *list_insert_head(list_t * list, void *data)
|
|||
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;
|
||||
|
||||
|
@ -103,7 +103,7 @@ list_node_t *list_insert_tail(list_t * list, void *data)
|
|||
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;
|
||||
|
@ -118,25 +118,25 @@ void list_unlink_node(list_t * list, list_node_t * node)
|
|||
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);
|
||||
}
|
||||
|
||||
void list_delete_head(list_t * list)
|
||||
void list_delete_head(list_t *list)
|
||||
{
|
||||
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 */
|
||||
|
||||
void *list_get_head(list_t * list)
|
||||
void *list_get_head(list_t *list)
|
||||
{
|
||||
if(list->head)
|
||||
return list->head->data;
|
||||
|
@ -144,7 +144,7 @@ void *list_get_head(list_t * list)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void *list_get_tail(list_t * list)
|
||||
void *list_get_tail(list_t *list)
|
||||
{
|
||||
if(list->tail)
|
||||
return list->tail->data;
|
||||
|
@ -154,7 +154,7 @@ void *list_get_tail(list_t * list)
|
|||
|
||||
/* Fast list deletion */
|
||||
|
||||
void list_delete_list(list_t * list)
|
||||
void list_delete_list(list_t *list)
|
||||
{
|
||||
list_node_t *node, *next;
|
||||
|
||||
|
@ -168,7 +168,7 @@ void list_delete_list(list_t * list)
|
|||
|
||||
/* 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;
|
||||
|
||||
|
@ -178,7 +178,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;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: list.h,v 1.1.2.7 2002/09/09 21:49:16 guus Exp $
|
||||
$Id: list.h,v 1.1.2.8 2002/09/09 22:32:27 guus Exp $
|
||||
*/
|
||||
|
||||
#ifndef __TINC_LIST_H__
|
||||
|
@ -32,8 +32,8 @@ typedef struct list_node_t {
|
|||
void *data;
|
||||
} list_node_t;
|
||||
|
||||
typedef void (*list_action_t) (const void *);
|
||||
typedef void (*list_action_node_t) (const list_node_t *);
|
||||
typedef void (*list_action_t)(const void *);
|
||||
typedef void (*list_action_node_t)(const list_node_t *);
|
||||
|
||||
typedef struct list_t {
|
||||
list_node_t *head;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue