svn commit: samba r4140 - in branches/SAMBA_4_0/source: include
lib/registry lib/registry/common
jelmer at samba.org
jelmer at samba.org
Fri Dec 10 22:57:43 GMT 2004
Author: jelmer
Date: 2004-12-10 22:57:43 +0000 (Fri, 10 Dec 2004)
New Revision: 4140
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4140
Log:
Get rid of close_hive (replace it with talloc destructors).
Modified:
branches/SAMBA_4_0/source/include/registry.h
branches/SAMBA_4_0/source/lib/registry/common/reg_interface.c
branches/SAMBA_4_0/source/lib/registry/reg_backend_ldb.c
Changeset:
Modified: branches/SAMBA_4_0/source/include/registry.h
===================================================================
--- branches/SAMBA_4_0/source/include/registry.h 2004-12-10 22:36:46 UTC (rev 4139)
+++ branches/SAMBA_4_0/source/include/registry.h 2004-12-10 22:57:43 UTC (rev 4140)
@@ -111,7 +111,6 @@
/* Implement this one */
WERROR (*open_hive) (struct registry_hive *, struct registry_key **);
- WERROR (*close_hive) (struct registry_hive *);
/* Or this one */
WERROR (*open_key) (TALLOC_CTX *, struct registry_key *, const char *name, struct registry_key **);
@@ -148,9 +147,9 @@
struct registry_hive {
const struct hive_operations *functions;
- char *location;
- void *backend_data;
struct registry_key *root;
+ void *backend_data;
+ const char *location;
struct registry_context *reg_ctx;
};
Modified: branches/SAMBA_4_0/source/lib/registry/common/reg_interface.c
===================================================================
--- branches/SAMBA_4_0/source/lib/registry/common/reg_interface.c 2004-12-10 22:36:46 UTC (rev 4139)
+++ branches/SAMBA_4_0/source/lib/registry/common/reg_interface.c 2004-12-10 22:57:43 UTC (rev 4140)
@@ -149,7 +149,8 @@
/* Open a registry file/host/etc */
WERROR reg_open_hive(struct registry_context *parent_ctx, const char *backend, const char *location, const char *credentials, struct registry_key **root)
{
- struct registry_hive *ret;
+ struct registry_hive *rethive;
+ struct registry_key *retkey;
struct reg_init_function_entry *entry;
WERROR werr;
@@ -164,28 +165,30 @@
return WERR_NOT_SUPPORTED;
}
- ret = talloc_p(parent_ctx, struct registry_hive);
- ret->location = location?talloc_strdup(ret, location):NULL;
- ret->functions = entry->hive_functions;
- ret->backend_data = NULL;
- ret->reg_ctx = parent_ctx;
+ rethive = talloc_p(parent_ctx, struct registry_hive);
+ rethive->location = location?talloc_strdup(rethive, location):NULL;
+ rethive->functions = entry->hive_functions;
+ rethive->backend_data = NULL;
+ rethive->reg_ctx = parent_ctx;
- werr = entry->hive_functions->open_hive(ret, &ret->root);
+ werr = entry->hive_functions->open_hive(rethive, &retkey);
+ rethive->root = retkey;
+
if(!W_ERROR_IS_OK(werr)) {
return werr;
}
- if(!ret->root) {
+ if(!retkey) {
DEBUG(0, ("Backend %s didn't provide root key!\n", backend));
return WERR_GENERAL_FAILURE;
}
- ret->root->hive = ret;
- ret->root->name = NULL;
- ret->root->path = talloc_strdup(ret, "");
+ retkey->hive = rethive;
+ retkey->name = NULL;
+ retkey->path = talloc_strdup(retkey, "");
- *root = ret->root;
+ *root = retkey;
return WERR_OK;
}
Modified: branches/SAMBA_4_0/source/lib/registry/reg_backend_ldb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/registry/reg_backend_ldb.c 2004-12-10 22:36:46 UTC (rev 4139)
+++ branches/SAMBA_4_0/source/lib/registry/reg_backend_ldb.c 2004-12-10 22:57:43 UTC (rev 4140)
@@ -29,6 +29,15 @@
int subkey_count, value_count;
};
+static int ldb_close_hive (void *_hive)
+{
+ struct registry_hive *hive = _hive;
+ ldb_close (hive->backend_data);
+ return 0;
+}
+
+
+
static int reg_close_ldb_key (void *data)
{
struct registry_key *key = data;
@@ -189,6 +198,7 @@
hive->root = talloc_zero_p(hive, struct registry_key);
talloc_set_destructor (hive->root, reg_close_ldb_key);
+ talloc_set_destructor (hive, ldb_close_hive);
hive->root->name = talloc_strdup(hive->root, "");
hive->root->backend_data = kd = talloc_zero_p(hive->root, struct ldb_key_data);
kd->dn = talloc_strdup(hive->root, "key=root");
@@ -240,18 +250,11 @@
return WERR_OK;
}
-static WERROR ldb_close_hive (struct registry_hive *hive)
-{
- ldb_close (hive->backend_data);
- return WERR_OK;
-}
-
static struct hive_operations reg_backend_ldb = {
.name = "ldb",
.add_key = ldb_add_key,
.del_key = ldb_del_key,
.open_hive = ldb_open_hive,
- .close_hive = ldb_close_hive,
.open_key = ldb_open_key,
.get_value_by_index = ldb_get_value_by_id,
.get_subkey_by_index = ldb_get_subkey_by_id,
More information about the samba-cvs
mailing list