From acf9d61421faa6c0055d57fdee7db300dc5431aa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 7 Dec 2004 18:25:53 +0000 Subject: r4088: Get medieval on our ass about malloc.... :-). Take control of all our allocation functions so we can funnel through some well known functions. Should help greatly with malloc checking. HEAD patch to follow. Jeremy. (This used to be commit 620f2e608f70ba92f032720c031283d295c5c06a) --- source3/lib/adt_tree.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source3/lib/adt_tree.c') diff --git a/source3/lib/adt_tree.c b/source3/lib/adt_tree.c index bd857e205a..a5d6380377 100644 --- a/source3/lib/adt_tree.c +++ b/source3/lib/adt_tree.c @@ -59,7 +59,7 @@ SORTED_TREE* sorted_tree_init( void *data_p, { SORTED_TREE *tree = NULL; - if ( !(tree = (SORTED_TREE*)malloc( sizeof(SORTED_TREE) )) ) + if ( !(tree = SMB_MALLOC_P(SORTED_TREE)) ) return NULL; ZERO_STRUCTP( tree ); @@ -67,7 +67,7 @@ SORTED_TREE* sorted_tree_init( void *data_p, tree->compare = cmp_fn; tree->free_func = free_fn; - if ( !(tree->root = (TREE_NODE*)malloc( sizeof(TREE_NODE) )) ) { + if ( !(tree->root = SMB_MALLOC_P(TREE_NODE)) ) { SAFE_FREE( tree ); return NULL; } @@ -126,15 +126,15 @@ static TREE_NODE* sorted_tree_birth_child( TREE_NODE *node, char* key ) TREE_NODE **siblings; int i; - if ( !(infant = (TREE_NODE*)malloc( sizeof(TREE_NODE) )) ) + if ( !(infant = SMB_MALLOC_P(TREE_NODE)) ) return NULL; ZERO_STRUCTP( infant ); - infant->key = strdup( key ); + infant->key = SMB_STRDUP( key ); infant->parent = node; - siblings = Realloc( node->children, sizeof(TREE_NODE*)*(node->num_children+1) ); + siblings = SMB_REALLOC_ARRAY( node->children, TREE_NODE *, node->num_children+1 ); if ( siblings ) node->children = siblings; @@ -260,7 +260,7 @@ BOOL sorted_tree_add( SORTED_TREE *tree, const char *path, void *data_p ) /* move past the first '/' */ path++; - path2 = strdup( path ); + path2 = SMB_STRDUP( path ); if ( !path2 ) { DEBUG(0,("sorted_tree_add: strdup() failed on string [%s]!?!?!\n", path)); return False; @@ -405,9 +405,9 @@ void* sorted_tree_find( SORTED_TREE *tree, char *key ) /* make a copy to play with */ if ( *key == '/' ) - keystr = strdup( key+1 ); + keystr = SMB_STRDUP( key+1 ); else - keystr = strdup( key ); + keystr = SMB_STRDUP( key ); if ( !keystr ) { DEBUG(0,("sorted_tree_find: strdup() failed on string [%s]!?!?!\n", key)); -- cgit