X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=lib%2Fjsw%2Fjsw_atree.c;h=82c24ca81aa1bef809df5b3bfca26d83a29c269b;hb=77544f57c8617cf232cdf21e02924ae03d4da685;hp=ba66bd0ccb6eb984c285a178c2b6f93383de0122;hpb=d37d830611a8dc438b2de37f68bf2f9ae1230490;p=zpackage diff --git a/lib/jsw/jsw_atree.c b/lib/jsw/jsw_atree.c index ba66bd0..82c24ca 100644 --- a/lib/jsw/jsw_atree.c +++ b/lib/jsw/jsw_atree.c @@ -13,17 +13,11 @@ 4) Bug in jsw_aerase: Search for successor should save the path */ -#include "jsw_atree.h" +#include "jsw.h" -#ifdef __cplusplus -#include - -using std::malloc; -using std::free; -using std::size_t; -#else #include -#endif +#include +#include #ifndef HEIGHT_LIMIT #define HEIGHT_LIMIT 64 /* Tallest allowable tree */ @@ -74,7 +68,7 @@ struct jsw_atrav { static jsw_anode_t *new_node ( jsw_atree_t *tree, void *data ) { - jsw_anode_t *rn = (jsw_anode_t *)malloc ( sizeof *rn ); + jsw_anode_t *rn = malloc ( sizeof *rn ); if ( rn == NULL ) return tree->nil; @@ -88,13 +82,13 @@ static jsw_anode_t *new_node ( jsw_atree_t *tree, void *data ) jsw_atree_t *jsw_anew ( cmp_f cmp, dup_f dup, rel_f rel ) { - jsw_atree_t *rt = (jsw_atree_t *)malloc ( sizeof *rt ); + jsw_atree_t *rt = malloc ( sizeof *rt ); if ( rt == NULL ) return NULL; /* Initialize sentinel */ - rt->nil = (jsw_anode_t *)malloc ( sizeof *rt->nil ); + rt->nil = malloc ( sizeof *rt->nil ); if ( rt->nil == NULL ) { free ( rt ); return NULL; @@ -142,12 +136,12 @@ void jsw_adelete ( jsw_atree_t *tree ) free ( tree ); } -void *jsw_afind ( jsw_atree_t *tree, void *data ) -{ +void *jsw_afind ( jsw_atree_t *tree, void *data) { jsw_anode_t *it = tree->root; + int cmp = 0; while ( it != tree->nil ) { - int cmp = tree->cmp ( it->data, data ); + cmp = tree->cmp(it->data, data); if ( cmp == 0 ) break;