Skip to content
Snippets Groups Projects
Commit f704f1c4 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

(barely) hide AVL internals

parent 322bb86f
No related branches found
No related tags found
No related merge requests found
...@@ -32,12 +32,15 @@ ...@@ -32,12 +32,15 @@
LDAP_BEGIN_DECL LDAP_BEGIN_DECL
typedef struct avlnode { typedef struct avlnode Avlnode;
#ifdef AVL_INTERNAL
struct avlnode {
void* avl_data; void* avl_data;
signed char avl_bf; signed char avl_bf;
struct avlnode *avl_left; struct avlnode *avl_left;
struct avlnode *avl_right; struct avlnode *avl_right;
} Avlnode; };
#define NULLAVL ((Avlnode *) NULL) #define NULLAVL ((Avlnode *) NULL)
...@@ -45,6 +48,7 @@ typedef struct avlnode { ...@@ -45,6 +48,7 @@ typedef struct avlnode {
#define LH (-1) #define LH (-1)
#define EH 0 #define EH 0
#define RH 1 #define RH 1
#endif
/* avl routines */ /* avl routines */
#define avl_getone(x) ((x) == 0 ? 0 : (x)->avl_data) #define avl_getone(x) ((x) == 0 ? 0 : (x)->avl_data)
......
...@@ -21,6 +21,7 @@ static char avl_version[] = "AVL library version 1.0\n"; ...@@ -21,6 +21,7 @@ static char avl_version[] = "AVL library version 1.0\n";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define AVL_INTERNAL
#include "avl.h" #include "avl.h"
#define ROTATERIGHT(x) { \ #define ROTATERIGHT(x) { \
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <ac/string.h> #include <ac/string.h>
#define AVL_INTERNAL
#define AVL_NONREENTRANT #define AVL_NONREENTRANT
#include "avl.h" #include "avl.h"
...@@ -16,7 +17,7 @@ static void myprint LDAP_P(( Avlnode *root )); ...@@ -16,7 +17,7 @@ static void myprint LDAP_P(( Avlnode *root ));
int int
main( int argc, char **argv ) main( int argc, char **argv )
{ {
Avlnode *tree = NULLAVL; Avlnode *tree = NULL;
char command[ 10 ]; char command[ 10 ];
char name[ 80 ]; char name[ 80 ];
char *p; char *p;
...@@ -26,7 +27,7 @@ main( int argc, char **argv ) ...@@ -26,7 +27,7 @@ main( int argc, char **argv )
switch( *command ) { switch( *command ) {
case 'n': /* new tree */ case 'n': /* new tree */
( void ) avl_free( tree, (AVL_FREE) free ); ( void ) avl_free( tree, (AVL_FREE) free );
tree = NULLAVL; tree = NULL;
break; break;
case 'p': /* print */ case 'p': /* print */
( void ) myprint( tree ); ( void ) myprint( tree );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment