From 413c2e9b0aed25ef49b4344c1aec145d0e45a51e Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 13 Apr 2008 00:54:44 +0200 Subject: registry: remove the REGISTRY_HOOKS layer from the reghook cache. There is no need to save the keyname again, we only need to get the REGISTRY_OPS out of the pathtree. Furthermore, this makes life easier, since we can now pass in keynames as temporarily allocated strings. Michael (This used to be commit 2f9ee2f782c77ed99669af5ac2ba40cb0978f0da) --- source3/registry/reg_cachehook.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'source3/registry/reg_cachehook.c') diff --git a/source3/registry/reg_cachehook.c b/source3/registry/reg_cachehook.c index f9851c7810..7ce39aff25 100644 --- a/source3/registry/reg_cachehook.c +++ b/source3/registry/reg_cachehook.c @@ -27,7 +27,6 @@ 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 if it has not been initialized yet. @@ -36,7 +35,7 @@ static REGISTRY_HOOK default_hook = { KEY_TREE_ROOT, ®db_ops }; bool reghook_cache_init( void ) { if (cache_tree == NULL) { - cache_tree = pathtree_init(&default_hook, NULL); + cache_tree = pathtree_init(®db_ops, NULL); if (cache_tree !=0) { DEBUG(10, ("reghook_cache_init: new tree with default " "ops %p for key [%s]\n", (void *)®db_ops, @@ -48,20 +47,20 @@ bool reghook_cache_init( void ) } /********************************************************************** - Add a new REGISTRY_HOOK to the cache. Note that the keyname + Add a new registry hook to the cache. Note that the keyname is not in the exact format that a SORTED_TREE expects. *********************************************************************/ -bool reghook_cache_add( REGISTRY_HOOK *hook ) +bool reghook_cache_add(const char *keyname, REGISTRY_OPS *ops) { TALLOC_CTX *ctx = talloc_tos(); char *key = NULL; - if (!hook) { + if ((keyname == NULL) || (ops == NULL)) { return false; } - key = talloc_asprintf(ctx, "\\%s", hook->keyname); + key = talloc_asprintf(ctx, "\\%s", keyname); if (!key) { return false; } @@ -71,20 +70,20 @@ bool reghook_cache_add( REGISTRY_HOOK *hook ) } DEBUG(10, ("reghook_cache_add: Adding ops %p for key [%s]\n", - (void *)hook->ops, key)); + (void *)ops, key)); - return pathtree_add( cache_tree, key, hook ); + return pathtree_add(cache_tree, key, ops); } /********************************************************************** Initialize the cache tree *********************************************************************/ -REGISTRY_HOOK* reghook_cache_find( const char *keyname ) +REGISTRY_OPS *reghook_cache_find(const char *keyname) { char *key; int len; - REGISTRY_HOOK *hook; + REGISTRY_OPS *ops; if ( !keyname ) return NULL; @@ -107,14 +106,14 @@ REGISTRY_HOOK* reghook_cache_find( const char *keyname ) DEBUG(10,("reghook_cache_find: Searching for keyname [%s]\n", key)); - hook = (REGISTRY_HOOK *)pathtree_find( cache_tree, key ) ; + ops = (REGISTRY_OPS *)pathtree_find(cache_tree, key); DEBUG(10, ("reghook_cache_find: found ops %p for key [%s]\n", - hook ? (void *)hook->ops : 0, key)); + ops ? (void *)ops : 0, key)); SAFE_FREE( key ); - return hook; + return ops; } /********************************************************************** -- cgit