--- libelwix/src/patricia.c 2013/01/17 10:05:35 1.1 +++ libelwix/src/patricia.c 2024/01/22 15:16:44 1.5.74.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: patricia.c,v 1.1 2013/01/17 10:05:35 misho Exp $ +* $Id: patricia.c,v 1.5.74.2 2024/01/22 15:16:44 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 +Copyright 2004 - 2015 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -213,12 +213,12 @@ static inline prefix_t *New_Prefix(int family, void *d // ------------------------------------------------------------------------------------ -inline char *prefix_toa(prefix_t * prefix) +char *prefix_toa(prefix_t * prefix) { return prefix_toa2x(prefix, NULL, 0); } -inline prefix_t *ascii2prefix(int family, char *string) +prefix_t *ascii2prefix(int family, char *string) { u_long bitlen, maxbitlen = 0; char *cp; @@ -257,7 +257,7 @@ inline prefix_t *ascii2prefix(int family, char *string memcpy(save, string, cp - string); save[cp - string] = 0; string = save; - if (bitlen < 0 || bitlen > maxbitlen) + if (bitlen > maxbitlen) bitlen = maxbitlen; } else bitlen = maxbitlen; @@ -279,7 +279,7 @@ inline prefix_t *ascii2prefix(int family, char *string return NULL; } -inline prefix_t *Ref_Prefix(prefix_t *prefix) +prefix_t *Ref_Prefix(prefix_t *prefix) { if (!prefix) return NULL; @@ -293,7 +293,7 @@ inline prefix_t *Ref_Prefix(prefix_t *prefix) return prefix; } -inline void Deref_Prefix(prefix_t *prefix) +void Deref_Prefix(prefix_t *prefix) { if (!prefix) return; @@ -309,7 +309,7 @@ inline void Deref_Prefix(prefix_t *prefix) /* } */ /* these routines support continuous mask only */ -inline patricia_tree_t *New_Patricia(int maxbits) +patricia_tree_t *New_Patricia(int maxbits) { patricia_tree_t *patricia; @@ -330,7 +330,7 @@ inline patricia_tree_t *New_Patricia(int maxbits) * if func is supplied, it will be called as func(node->data) * before deleting the node */ -inline void Clear_Patricia(patricia_tree_t *patricia, void_fn_t func) +void Clear_Patricia(patricia_tree_t *patricia, void_fn_t func) { assert(patricia); if (patricia->head) { @@ -368,7 +368,7 @@ inline void Clear_Patricia(patricia_tree_t *patricia, /* Delete(patricia); */ } -inline void Destroy_Patricia(patricia_tree_t *patricia, void_fn_t func) +void Destroy_Patricia(patricia_tree_t *patricia, void_fn_t func) { Clear_Patricia(patricia, func); Delete(patricia); @@ -379,7 +379,7 @@ inline void Destroy_Patricia(patricia_tree_t *patricia /* * if func is supplied, it will be called as func(node->prefix, node->data) */ -inline void patricia_process(patricia_tree_t *patricia, void_fn_t func) +void patricia_process(patricia_tree_t *patricia, void_fn_t func) { patricia_node_t *node; @@ -391,7 +391,7 @@ inline void patricia_process(patricia_tree_t *patricia } -inline patricia_node_t *patricia_search_exact(patricia_tree_t *patricia, prefix_t *prefix) +patricia_node_t *patricia_search_exact(patricia_tree_t *patricia, prefix_t *prefix) { patricia_node_t *node; u_char *addr; @@ -459,7 +459,7 @@ inline patricia_node_t *patricia_search_exact(patricia /* if inclusive != 0, "best" may be the given prefix itself */ -inline patricia_node_t *patricia_search_best2(patricia_tree_t *patricia, prefix_t *prefix, int inclusive) +patricia_node_t *patricia_search_best2(patricia_tree_t *patricia, prefix_t *prefix, int inclusive) { patricia_node_t *node; patricia_node_t *stack[PATRICIA_MAXBITS + 1]; @@ -549,13 +549,13 @@ inline patricia_node_t *patricia_search_best2(patricia return NULL; } -inline patricia_node_t *patricia_search_best(patricia_tree_t *patricia, prefix_t *prefix) +patricia_node_t *patricia_search_best(patricia_tree_t *patricia, prefix_t *prefix) { return patricia_search_best2(patricia, prefix, 1); } -inline patricia_node_t *patricia_lookup(patricia_tree_t *patricia, prefix_t *prefix) +patricia_node_t *patricia_lookup(patricia_tree_t *patricia, prefix_t *prefix) { patricia_node_t *node, *new_node, *parent, *glue; u_char *addr, *test_addr; @@ -759,7 +759,7 @@ inline patricia_node_t *patricia_lookup(patricia_tree_ } -inline void patricia_remove(patricia_tree_t *patricia, patricia_node_t *node) +void patricia_remove(patricia_tree_t *patricia, patricia_node_t *node) { patricia_node_t *parent, *child; @@ -860,7 +860,7 @@ inline void patricia_remove(patricia_tree_t *patricia, /* { from demo.c */ -inline void lookup_then_remove(patricia_tree_t *tree, char *string) +void lookup_then_remove(patricia_tree_t *tree, char *string) { patricia_node_t *node; @@ -868,7 +868,7 @@ inline void lookup_then_remove(patricia_tree_t *tree, patricia_remove(tree, node); } -inline patricia_node_t *make_and_lookup(patricia_tree_t *tree, char *string) +patricia_node_t *make_and_lookup(patricia_tree_t *tree, char *string) { prefix_t *prefix; patricia_node_t *node; @@ -883,7 +883,7 @@ inline patricia_node_t *make_and_lookup(patricia_tree_ return node; } -inline patricia_node_t *try_search_exact(patricia_tree_t *tree, char *string) +patricia_node_t *try_search_exact(patricia_tree_t *tree, char *string) { prefix_t *prefix; patricia_node_t *node; @@ -904,7 +904,7 @@ inline patricia_node_t *try_search_exact(patricia_tree return node; } -inline patricia_node_t *try_search_best(patricia_tree_t *tree, char *string) +patricia_node_t *try_search_best(patricia_tree_t *tree, char *string) { prefix_t *prefix; patricia_node_t *node;