diff options
author | Michael Adam <obnox@samba.org> | 2008-04-13 00:54:44 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2008-04-13 01:43:42 +0200 |
commit | 413c2e9b0aed25ef49b4344c1aec145d0e45a51e (patch) | |
tree | 99fdbd0329245d4e73b5f3e3ae3981c8d0819e01 /source3/registry/reg_cachehook.c | |
parent | a75421b0190763e5e482db215d8b1e6052bdcc19 (diff) | |
download | samba-413c2e9b0aed25ef49b4344c1aec145d0e45a51e.tar.gz samba-413c2e9b0aed25ef49b4344c1aec145d0e45a51e.tar.bz2 samba-413c2e9b0aed25ef49b4344c1aec145d0e45a51e.zip |
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)
Diffstat (limited to 'source3/registry/reg_cachehook.c')
-rw-r--r-- | source3/registry/reg_cachehook.c | 25 |
1 files changed, 12 insertions, 13 deletions
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; } /********************************************************************** |