summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_tdb
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2006-08-01 03:22:02 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:15:18 -0500
commitb1b9617d1c1833da2efa93b011733060c6670976 (patch)
tree051a698013674bb960926119377f52ae09be0a0f /source4/lib/ldb/ldb_tdb
parentb94b9d8c3d7b99294eb48437894d8c6901e9dc70 (diff)
downloadsamba-b1b9617d1c1833da2efa93b011733060c6670976.tar.gz
samba-b1b9617d1c1833da2efa93b011733060c6670976.tar.bz2
samba-b1b9617d1c1833da2efa93b011733060c6670976.zip
r17350: Avoid a couple of memleaks, unnecessary code and use a more linear style
(This used to be commit 97c4d41a30a5d85145abb781cb7001b502bc7dcb)
Diffstat (limited to 'source4/lib/ldb/ldb_tdb')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c39
1 files changed, 12 insertions, 27 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index 588f73fe23..7ee715f561 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -270,41 +270,26 @@ static int ltdb_add_internal(struct ldb_module *module, const struct ldb_message
}
ret = ltdb_store(module, msg, TDB_INSERT);
- switch (ret) {
- case LDB_SUCCESS:
- {
- TALLOC_CTX *mem_ctx = talloc_new(module);
+
+ if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS) {
char *dn;
- dn = ldb_dn_linearize(mem_ctx, msg->dn);
+
+ dn = ldb_dn_linearize(module, msg->dn);
if (!dn) {
- break;
+ return ret;
}
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "Entry %s already exists", dn));
+ talloc_free(dn);
+ return ret;
+ }
+
+ if (ret == LDB_SUCCESS) {
ret = ltdb_modified(module, msg->dn);
if (ret != LDB_SUCCESS) {
return LDB_ERR_OPERATIONS_ERROR;
}
- break;
- }
- case LDB_ERR_ENTRY_ALREADY_EXISTS:
- {
- TALLOC_CTX *mem_ctx = talloc_new(module);
- char *errstring, *dn;
- if (!mem_ctx) {
- break;
- }
- dn = ldb_dn_linearize(mem_ctx, msg->dn);
- if (!dn) {
- break;
- }
- errstring = talloc_asprintf(mem_ctx, "Entry %s already exists",
- dn);
- ldb_set_errstring(module->ldb, errstring);
- talloc_free(mem_ctx);
- break;
- }
- default:
- break;
}
+
return ret;
}