summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_tdb/ldb_cache.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-05-05 04:27:29 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:51:45 -0500
commit232bc1503fc0e3f85b4711f077d2566dc0f0c823 (patch)
tree14e4a2736ab44368bdb27296ddbe5fb3a05fd5fc /source4/lib/ldb/ldb_tdb/ldb_cache.c
parentaf66c31e44bcb052f35f9b1de8e997149fddac89 (diff)
downloadsamba-232bc1503fc0e3f85b4711f077d2566dc0f0c823.tar.gz
samba-232bc1503fc0e3f85b4711f077d2566dc0f0c823.tar.bz2
samba-232bc1503fc0e3f85b4711f077d2566dc0f0c823.zip
r490: - expanded the test suite to test modify and delete operations
- made yet another attempt to make ldb const clean. - "make test" now runs both the tdb and ldap backend tests, and run the ldbtest utility with and without indexing - added prototypes in ldb.h for ldb_msg_*() public functions (This used to be commit 01e87406768cb5a98ac8530a2f361a4987a36cd3)
Diffstat (limited to 'source4/lib/ldb/ldb_tdb/ldb_cache.c')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_cache.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_cache.c b/source4/lib/ldb/ldb_tdb/ldb_cache.c
index 5d61fd35b3..3c6ce63c2b 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_cache.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_cache.c
@@ -44,20 +44,42 @@ static int ltdb_baseinfo_init(struct ldb_context *ldb)
struct ldb_message msg;
struct ldb_message_element el;
struct ldb_val val;
+ int ret;
ltdb->sequence_number = 0;
msg.num_elements = 1;
msg.elements = &el;
- msg.dn = LTDB_BASEINFO;
- el.name = LTDB_SEQUENCE_NUMBER;
+ msg.dn = strdup(LTDB_BASEINFO);
+ if (!msg.dn) {
+ errno = ENOMEM;
+ return -1;
+ }
+ el.name = strdup(LTDB_SEQUENCE_NUMBER);
+ if (!el.name) {
+ free(msg.dn);
+ errno = ENOMEM;
+ return -1;
+ }
el.values = &val;
el.num_values = 1;
el.flags = 0;
- val.data = "0";
+ val.data = strdup("0");
+ if (!val.data) {
+ free(el.name);
+ free(msg.dn);
+ errno = ENOMEM;
+ return -1;
+ }
val.length = 1;
- return ltdb_store(ldb, &msg, TDB_INSERT);
+ ret = ltdb_store(ldb, &msg, TDB_INSERT);
+
+ free(msg.dn);
+ free(el.name);
+ free(val.data);
+
+ return ret;
}
/*
@@ -150,8 +172,8 @@ int ltdb_increase_sequence_number(struct ldb_context *ldb)
msg.num_elements = 1;
msg.elements = &el;
- msg.dn = LTDB_BASEINFO;
- el.name = LTDB_SEQUENCE_NUMBER;
+ msg.dn = strdup(LTDB_BASEINFO);
+ el.name = strdup(LTDB_SEQUENCE_NUMBER);
el.values = &val;
el.num_values = 1;
el.flags = LDB_FLAG_MOD_REPLACE;
@@ -161,6 +183,8 @@ int ltdb_increase_sequence_number(struct ldb_context *ldb)
ret = ltdb_modify_internal(ldb, &msg);
free(s);
+ free(msg.dn);
+ free(el.name);
if (ret == 0) {
ltdb->sequence_number += 1;