diff options
author | Michael Adam <obnox@samba.org> | 2008-01-03 12:07:02 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2008-01-03 12:07:02 +0100 |
commit | 0240d175bf896230891a3ffadba747a0143d9232 (patch) | |
tree | 15a0d4942685131732952f327c34995308da5ca5 /source3/registry | |
parent | 984aa7a1560a4d052a0c8260d230be4b89303bd7 (diff) | |
download | samba-0240d175bf896230891a3ffadba747a0143d9232.tar.gz samba-0240d175bf896230891a3ffadba747a0143d9232.tar.bz2 samba-0240d175bf896230891a3ffadba747a0143d9232.zip |
Return existsing cache_tree if it has already been initialized.
So reghook_cache_init() does not leak memory when called more
than once.
Also, fix the return value while we are at it.
Michael
(This used to be commit 25f571f40a630bff5a47bba6b01e42d4e0ffed66)
Diffstat (limited to 'source3/registry')
-rw-r--r-- | source3/registry/reg_cachehook.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/source3/registry/reg_cachehook.c b/source3/registry/reg_cachehook.c index 289d4e50ce..74670aac30 100644 --- a/source3/registry/reg_cachehook.c +++ b/source3/registry/reg_cachehook.c @@ -25,19 +25,21 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_REGISTRY -static SORTED_TREE *cache_tree; +static SORTED_TREE *cache_tree = NULL; extern REGISTRY_OPS regdb_ops; /* these are the default */ static REGISTRY_HOOK default_hook = { KEY_TREE_ROOT, ®db_ops }; /********************************************************************** - Initialize the cache tree + Initialize the cache tree if it has not been initialized yet. *********************************************************************/ bool reghook_cache_init( void ) { - cache_tree = pathtree_init( &default_hook, NULL ); + if (cache_tree == NULL) { + cache_tree = pathtree_init(&default_hook, NULL); + } - return ( cache_tree == NULL ); + return (cache_tree != NULL); } /********************************************************************** |