[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Sat Feb 13 05:47:04 MST 2010


The branch, master has been updated
       via  613777e... s3: Remove unused comparison fn from "struct sorted_tree"
       via  3ab78e3... s3: Make adt_tree data definitions private to adt_tree.c
       via  2260732... s3: SORTED_TREE -> struct sorted_tree
       via  ceebed6... s3: TREE_NODE -> struct tree_node
       via  65b26ba... s3: Fix some nonempty blank lines
       via  e371317... use ZERO_STRUCT
       via  95ca53f... Use ZERO_STRUCTP
       via  1a995ab... s3: Fix a typo
       via  ece99c7... s3: Fix a C++ warning
      from  f69135e... s4-smbd: fix crash in notify code on client termination

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 613777e6dce53fc3c8794ef6cf5d00688ee442e5
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Feb 7 15:49:13 2010 +0100

    s3: Remove unused comparison fn from "struct sorted_tree"

commit 3ab78e31f095639a77ea3c086e765d91424fa6fa
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Feb 7 15:47:07 2010 +0100

    s3: Make adt_tree data definitions private to adt_tree.c

commit 22607320841100148dbaed17983be7703d2172b1
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Feb 7 15:45:42 2010 +0100

    s3: SORTED_TREE -> struct sorted_tree

commit ceebed6ce19a5821b01a30f6ebc47871b27b413a
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Feb 7 15:42:26 2010 +0100

    s3: TREE_NODE -> struct tree_node

commit 65b26ba985c0882a3380f8fdde8405d98df6de55
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Feb 7 15:01:57 2010 +0100

    s3: Fix some nonempty blank lines

commit e3713176860dce07255c8ee773eaa4715323c9e7
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Feb 7 17:57:56 2010 +0100

    use ZERO_STRUCT

commit 95ca53f3e05ac31b05df64412ed1644fa03f99cb
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Feb 7 17:59:51 2010 +0100

    Use ZERO_STRUCTP

commit 1a995ab51e1ce236d713e20e264b8c65146b8ec4
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Feb 7 17:53:29 2010 +0100

    s3: Fix a typo

commit ece99c763acdc8a9b98ace4b8b08dfccbb1c9cb3
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Feb 13 13:02:15 2010 +0100

    s3: Fix a C++ warning

-----------------------------------------------------------------------

Summary of changes:
 lib/util/util_net.c              |    7 +-
 source3/include/adt_tree.h       |   25 +----
 source3/lib/adt_tree.c           |  195 ++++++++++++++++++++-----------------
 source3/registry/reg_cachehook.c |    6 +-
 source3/smbd/service.c           |    2 +-
 5 files changed, 118 insertions(+), 117 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/util_net.c b/lib/util/util_net.c
index 0ce495e..9e47f51 100644
--- a/lib/util/util_net.c
+++ b/lib/util/util_net.c
@@ -35,7 +35,7 @@
 
 void zero_sockaddr(struct sockaddr_storage *pss)
 {
-	memset(pss, '\0', sizeof(*pss));
+	ZERO_STRUCTP(pss);
 	/* Ensure we're at least a valid sockaddr-storage. */
 	pss->ss_family = AF_INET;
 }
@@ -49,12 +49,13 @@ bool interpret_string_addr_internal(struct addrinfo **ppres,
 	int ret;
 	struct addrinfo hints;
 
-	memset(&hints, '\0', sizeof(hints));
+	ZERO_STRUCT(hints);
+
 	/* By default make sure it supports TCP. */
 	hints.ai_socktype = SOCK_STREAM;
 	hints.ai_flags = flags;
 
-	/* Linux man page on getaddinfo() says port will be
+	/* Linux man page on getaddrinfo() says port will be
 	   uninitialized when service string in NULL */
 
 	ret = getaddrinfo(str, NULL,
diff --git a/source3/include/adt_tree.h b/source3/include/adt_tree.h
index 3acda8e..c2a869b 100644
--- a/source3/include/adt_tree.h
+++ b/source3/include/adt_tree.h
@@ -20,22 +20,7 @@
 #ifndef ADT_TREE_H
 #define ADT_TREE_H
 
-/* data structure used to build the tree */
-
-typedef struct _tree_node {
-	struct _tree_node	*parent;
-	struct _tree_node	**children;
-	int 			num_children;
-	char			*key;
-	void			*data_p;
-} TREE_NODE;
-
-typedef struct _tree_root {
-	TREE_NODE	*root;
-
-	/* not used currently (is it needed?) */
-	int 		(*compare)(void* x, void *y);
-} SORTED_TREE;
+struct sorted_tree;
 
 /* 
  * API
@@ -43,19 +28,19 @@ typedef struct _tree_root {
 
 /* create a new tree, talloc_free() to throw it away */
 
-SORTED_TREE*  pathtree_init( void *data_p, int (cmp_fn)(void*, void*) );
+struct sorted_tree *pathtree_init(void *data_p);
 
 /* add a new path component */
 
-WERROR        pathtree_add( SORTED_TREE *tree, const char *path, void *data_p );
+WERROR pathtree_add(struct sorted_tree *tree, const char *path, void *data_p );
 
 /* search path */
 
-void*         pathtree_find( SORTED_TREE *tree, char *key );
+void *pathtree_find(struct sorted_tree *tree, char *key );
 
 /* debug (print) functions */
 
-void          pathtree_print_keys( SORTED_TREE *tree, int debug );
+void pathtree_print_keys(struct sorted_tree *tree, int debug );
 
 
 #endif
diff --git a/source3/lib/adt_tree.c b/source3/lib/adt_tree.c
index 6ac498d..7f4a39d 100644
--- a/source3/lib/adt_tree.c
+++ b/source3/lib/adt_tree.c
@@ -20,6 +20,17 @@
 #include "includes.h"
 #include "adt_tree.h"
 
+struct tree_node {
+	struct tree_node	*parent;
+	struct tree_node	**children;
+	int 			num_children;
+	char			*key;
+	void			*data_p;
+};
+
+struct sorted_tree {
+	struct tree_node *root;
+};
 
 /**************************************************************************
  *************************************************************************/
@@ -27,46 +38,45 @@
 static bool trim_tree_keypath( char *path, char **base, char **new_path )
 {
 	char *p;
-	
+
 	*new_path = *base = NULL;
-	
+
 	if ( !path )
 		return False;
-	
+
 	*base = path;
-	
+
 	p = strchr( path, '/' );
-	
+
 	if ( p ) {
 		*p = '\0';
 		*new_path = p+1;
 	}
-	
+
 	return True;
 }
 
- 
 /**************************************************************************
- Initialize the tree's root.  The cmp_fn is a callback function used
- for comparision of two children
+ Initialize the tree's root.
  *************************************************************************/
 
- SORTED_TREE* pathtree_init( void *data_p, int (cmp_fn)(void*, void*) )
+struct sorted_tree *pathtree_init(void *data_p)
 {
-	SORTED_TREE *tree = NULL;
-	
-	if ( !(tree = TALLOC_ZERO_P(NULL, SORTED_TREE)) )
+	struct sorted_tree *tree = NULL;
+
+	tree = talloc_zero(NULL, struct sorted_tree);
+	if (tree == NULL) {
 		return NULL;
-		
-	tree->compare = cmp_fn;
-	
-	if ( !(tree->root = TALLOC_ZERO_P(tree, TREE_NODE)) ) {
+	}
+
+	tree->root = talloc_zero(tree, struct tree_node);
+	if (tree->root == NULL) {
 		TALLOC_FREE( tree );
 		return NULL;
 	}
-	
+
 	tree->root->data_p = data_p;
-	
+
 	return tree;
 }
 
@@ -75,27 +85,31 @@ static bool trim_tree_keypath( char *path, char **base, char **new_path )
  Find the next child given a key string
  *************************************************************************/
 
-static TREE_NODE* pathtree_birth_child( TREE_NODE *node, char* key )
+static struct tree_node *pathtree_birth_child(struct tree_node *node,
+					      char* key )
 {
-	TREE_NODE *infant = NULL;
-	TREE_NODE **siblings;
+	struct tree_node *infant = NULL;
+	struct tree_node **siblings;
 	int i;
-	
-	if ( !(infant = TALLOC_ZERO_P( node, TREE_NODE)) )
+
+	infant = talloc_zero(node, struct tree_node);
+	if (infant == NULL) {
 		return NULL;
-	
+	}
+
 	infant->key = talloc_strdup( infant, key );
 	infant->parent = node;
-	
-	siblings = TALLOC_REALLOC_ARRAY( node, node->children, TREE_NODE *, node->num_children+1 );
-	
+
+	siblings = talloc_realloc(node, node->children, struct tree_node *,
+				  node->num_children+1);
+
 	if ( siblings )
 		node->children = siblings;
-	
+
 	node->num_children++;
-	
+
 	/* first child */
-	
+
 	if ( node->num_children == 1 ) {
 		DEBUG(11,("pathtree_birth_child: First child of node [%s]! [%s]\n", 
 			node->key ? node->key : "NULL", infant->key ));
@@ -111,32 +125,32 @@ static TREE_NODE* pathtree_birth_child( TREE_NODE *node, char* key )
 		 * Insert the new infanct in ascending order 
 		 * from left to right
 		 */
-	
+
 		for ( i = node->num_children-1; i>=1; i-- )
 		{
 			DEBUG(11,("pathtree_birth_child: Looking for crib; infant -> [%s], child -> [%s]\n",
 				infant->key, node->children[i-1]->key));
-			
+
 			/* the strings should never match assuming that we 
 			   have called pathtree_find_child() first */
-		
+
 			if ( StrCaseCmp( infant->key, node->children[i-1]->key ) > 0 ) {
 				DEBUG(11,("pathtree_birth_child: storing infant in i == [%d]\n", 
 					i));
 				node->children[i] = infant;
 				break;
 			}
-			
+
 			/* bump everything towards the end on slot */
-			
+
 			node->children[i] = node->children[i-1];
 		}
 
 		DEBUG(11,("pathtree_birth_child: Exiting loop (i == [%d])\n", i ));
-		
+
 		/* if we haven't found the correct slot yet, the child 
 		   will be first in the list */
-		   
+
 		if ( i == 0 )
 			node->children[0] = infant;
 	}
@@ -148,42 +162,43 @@ static TREE_NODE* pathtree_birth_child( TREE_NODE *node, char* key )
  Find the next child given a key string
  *************************************************************************/
 
-static TREE_NODE* pathtree_find_child( TREE_NODE *node, char* key )
+static struct tree_node *pathtree_find_child(struct tree_node *node,
+					     char *key )
 {
-	TREE_NODE *next = NULL;
+	struct tree_node *next = NULL;
 	int i, result;
-	
+
 	if ( !node ) {
 		DEBUG(0,("pathtree_find_child: NULL node passed into function!\n"));
 		return NULL;
 	}
-	
+
 	if ( !key ) {
 		DEBUG(0,("pathtree_find_child: NULL key string passed into function!\n"));
 		return NULL;
 	}
-	
+
 	for ( i=0; i<node->num_children; i++ )
 	{	
 		DEBUG(11,("pathtree_find_child: child key => [%s]\n",
 			node->children[i]->key));
-			
+
 		result = StrCaseCmp( node->children[i]->key, key );
-		
+
 		if ( result == 0 )
 			next = node->children[i];
-		
+
 		/* if result > 0 then we've gone to far because
 		   the list of children is sorted by key name 
 		   If result == 0, then we have a match         */
-		   
+
 		if ( result > 0 )
 			break;
 	}
 
 	DEBUG(11,("pathtree_find_child: %s [%s]\n",
 		next ? "Found" : "Did not find", key ));	
-	
+
 	return next;
 }
 
@@ -191,54 +206,54 @@ static TREE_NODE* pathtree_find_child( TREE_NODE *node, char* key )
  Add a new node into the tree given a key path and a blob of data
  *************************************************************************/
 
- WERROR pathtree_add( SORTED_TREE *tree, const char *path, void *data_p )
+WERROR pathtree_add(struct sorted_tree *tree, const char *path, void *data_p)
 {
 	char *str, *base, *path2;
-	TREE_NODE *current, *next;
+	struct tree_node *current, *next;
 	WERROR ret = WERR_OK;
-	
+
 	DEBUG(8,("pathtree_add: Enter\n"));
-		
+
 	if ( !path || *path != '/' ) {
 		DEBUG(0,("pathtree_add: Attempt to add a node with a bad path [%s]\n",
 			path ? path : "NULL" ));
 		return WERR_INVALID_PARAM;
 	}
-	
+
 	if ( !tree ) {
 		DEBUG(0,("pathtree_add: Attempt to add a node to an uninitialized tree!\n"));
 		return WERR_INVALID_PARAM;
 	}
-	
+
 	/* move past the first '/' */
-	
+
 	path++;	
 	path2 = SMB_STRDUP( path );
 	if ( !path2 ) {
 		DEBUG(0,("pathtree_add: strdup() failed on string [%s]!?!?!\n", path));
 		return WERR_NOMEM;
 	}
-	
+
 
 	/* 
 	 * this works sort of like a 'mkdir -p'	call, possibly 
 	 * creating an entire path to the new node at once
 	 * The path should be of the form /<key1>/<key2>/...
 	 */
-	
+
 	base = path2;
 	str  = path2;
 	current = tree->root;
-	
+
 	do {
 		/* break off the remaining part of the path */
-		
+
 		str = strchr( str, '/' );
 		if ( str )
 			*str = '\0';
-			
+
 		/* iterate to the next child--birth it if necessary */
-		
+
 		next = pathtree_find_child( current, base );
 		if ( !next ) {
 			next = pathtree_birth_child( current, base );
@@ -249,20 +264,20 @@ static TREE_NODE* pathtree_find_child( TREE_NODE *node, char* key )
 			}
 		}
 		current = next;
-		
+
 		/* setup the next part of the path */
-		
+
 		base = str;
 		if ( base ) {
 			*base = '/';
 			base++;
 			str = base;
 		}
-	
+
 	} while ( base != NULL );
-	
+
 	current->data_p = data_p;
-	
+
 	DEBUG(10,("pathtree_add: Successfully added node [%s] to tree\n",
 		path ));
 
@@ -275,11 +290,11 @@ done:
 
 
 /**************************************************************************
- Recursive routine to print out all children of a TREE_NODE
+ Recursive routine to print out all children of a struct tree_node
  *************************************************************************/
 
 static void pathtree_print_children(TALLOC_CTX *ctx,
-				TREE_NODE *node,
+				struct tree_node *node,
 				int debug,
 				const char *path )
 {
@@ -319,7 +334,7 @@ static void pathtree_print_children(TALLOC_CTX *ctx,
  Dump the kys for a tree to the log file
  *************************************************************************/
 
- void pathtree_print_keys( SORTED_TREE *tree, int debug )
+void pathtree_print_keys(struct sorted_tree *tree, int debug )
 {
 	int i;
 	int num_children = tree->root->num_children;
@@ -343,87 +358,87 @@ static void pathtree_print_children(TALLOC_CTX *ctx,
  the tree
  *************************************************************************/
 
- void* pathtree_find( SORTED_TREE *tree, char *key )
+void* pathtree_find(struct sorted_tree *tree, char *key )
 {
 	char *keystr, *base = NULL, *str = NULL, *p;
-	TREE_NODE *current;
+	struct tree_node *current;
 	void *result = NULL;
-	
+
 	DEBUG(10,("pathtree_find: Enter [%s]\n", key ? key : "NULL" ));
 
 	/* sanity checks first */
-	
+
 	if ( !key ) {
 		DEBUG(0,("pathtree_find: Attempt to search tree using NULL search string!\n"));
 		return NULL;
 	}
-	
+
 	if ( !tree ) {
 		DEBUG(0,("pathtree_find: Attempt to search an uninitialized tree using string [%s]!\n",
 			key ? key : "NULL" ));
 		return NULL;
 	}
-	
+
 	if ( !tree->root )
 		return NULL;
-	
+
 	/* make a copy to play with */
-	
+
 	if ( *key == '/' )
 		keystr = SMB_STRDUP( key+1 );
 	else
 		keystr = SMB_STRDUP( key );
-	
+
 	if ( !keystr ) {
 		DEBUG(0,("pathtree_find: strdup() failed on string [%s]!?!?!\n", key));
 		return NULL;
 	}
 
 	/* start breaking the path apart */
-	
+
 	p = keystr;
 	current = tree->root;
-	
+
 	if ( tree->root->data_p )
 		result = tree->root->data_p;
-		
+
 	do
 	{
 		/* break off the remaining part of the path */
 
 		trim_tree_keypath( p, &base, &str );
-			
+
 		DEBUG(11,("pathtree_find: [loop] base => [%s], new_path => [%s]\n", 
 			base ? base : "",
 			str ? str : ""));
 
 		/* iterate to the next child */
-		
+
 		current = pathtree_find_child( current, base );
-	
+


-- 
Samba Shared Repository


More information about the samba-cvs mailing list