svn commit: samba r13258 - in
branches/SAMBA_4_0/source/lib/ldb/ldb_tdb: .
abartlet at samba.org
abartlet at samba.org
Tue Jan 31 11:16:44 GMT 2006
Author: abartlet
Date: 2006-01-31 11:16:43 +0000 (Tue, 31 Jan 2006)
New Revision: 13258
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=13258
Log:
Fix the talloc heirachy for ldb_tdb.
In the return value res->msgs, msgs was not a child of res, in the
indexed path. Instead, it hung directly off the ldb, which was
sometimes a long-term context.
Also remove unused parameters.
Found by --leak-report-full
Andrew Bartlett
Modified:
branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c
branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_search.c
branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.h
Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c 2006-01-31 10:39:45 UTC (rev 13257)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c 2006-01-31 11:16:43 UTC (rev 13258)
@@ -665,7 +665,8 @@
ret = 0;
if (ldb_match_msg(module->ldb, msg, tree, base, scope) == 1) {
- ret = ltdb_add_attr_results(module, msg, attrs, &(res->count), &(res->msgs));
+ ret = ltdb_add_attr_results(module, res, msg,
+ attrs, &(res->count), &(res->msgs));
}
talloc_free(msg);
if (ret != 0) {
Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_search.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_search.c 2006-01-31 10:39:45 UTC (rev 13257)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_search.c 2006-01-31 11:16:43 UTC (rev 13258)
@@ -40,8 +40,7 @@
/*
add one element to a message
*/
-static int msg_add_element(struct ldb_context *ldb,
- struct ldb_message *ret,
+static int msg_add_element(struct ldb_message *ret,
const struct ldb_message_element *el,
int check_duplicates)
{
@@ -92,7 +91,7 @@
/*
add the special distinguishedName element
*/
-static int msg_add_distinguished_name(struct ldb_module *module, struct ldb_message *msg)
+static int msg_add_distinguished_name(struct ldb_message *msg)
{
struct ldb_message_element el;
struct ldb_val val;
@@ -105,7 +104,7 @@
val.data = (uint8_t *)ldb_dn_linearize(msg, msg->dn);
val.length = strlen((char *)val.data);
- ret = msg_add_element(module->ldb, msg, &el, 1);
+ ret = msg_add_element(msg, &el, 1);
return ret;
}
@@ -119,7 +118,7 @@
unsigned int i;
int check_duplicates = (ret->num_elements != 0);
- if (msg_add_distinguished_name(module, ret) != 0) {
+ if (msg_add_distinguished_name(ret) != 0) {
return -1;
}
@@ -129,7 +128,7 @@
if (h->flags & LDB_ATTR_FLAG_HIDDEN) {
continue;
}
- if (msg_add_element(ldb, ret, &msg->elements[i],
+ if (msg_add_element(ret, &msg->elements[i],
check_duplicates) != 0) {
return -1;
}
@@ -143,14 +142,14 @@
pull the specified list of attributes from a message
*/
static struct ldb_message *ltdb_pull_attrs(struct ldb_module *module,
+ TALLOC_CTX *mem_ctx,
const struct ldb_message *msg,
const char * const *attrs)
{
- struct ldb_context *ldb = module->ldb;
struct ldb_message *ret;
int i;
- ret = talloc(ldb, struct ldb_message);
+ ret = talloc(mem_ctx, struct ldb_message);
if (!ret) {
return NULL;
}
@@ -184,7 +183,7 @@
}
if (ldb_attr_cmp(attrs[i], "distinguishedName") == 0) {
- if (msg_add_distinguished_name(module, ret) != 0) {
+ if (msg_add_distinguished_name(ret) != 0) {
return NULL;
}
continue;
@@ -194,7 +193,7 @@
if (!el) {
continue;
}
- if (msg_add_element(ldb, ret, el, 1) != 0) {
+ if (msg_add_element(ret, el, 1) != 0) {
talloc_free(ret);
return NULL;
}
@@ -296,23 +295,24 @@
add a set of attributes from a record to a set of results
return 0 on success, -1 on failure
*/
-int ltdb_add_attr_results(struct ldb_module *module, struct ldb_message *msg,
+int ltdb_add_attr_results(struct ldb_module *module,
+ TALLOC_CTX *mem_ctx,
+ struct ldb_message *msg,
const char * const attrs[],
unsigned int *count,
struct ldb_message ***res)
{
- struct ldb_context *ldb = module->ldb;
struct ldb_message *msg2;
struct ldb_message **res2;
/* pull the attributes that the user wants */
- msg2 = ltdb_pull_attrs(module, msg, attrs);
+ msg2 = ltdb_pull_attrs(module, mem_ctx, msg, attrs);
if (!msg2) {
return -1;
}
/* add to the results list */
- res2 = talloc_realloc(ldb, *res, struct ldb_message *, (*count)+2);
+ res2 = talloc_realloc(mem_ctx, *res, struct ldb_message *, (*count)+2);
if (!res2) {
talloc_free(msg2);
return -1;
@@ -385,7 +385,7 @@
return 0;
}
- ret = ltdb_add_attr_results(sinfo->module, msg, sinfo->attrs, &sinfo->count, &sinfo->msgs);
+ ret = ltdb_add_attr_results(sinfo->module, sinfo, msg, sinfo->attrs, &sinfo->count, &sinfo->msgs);
if (ret == -1) {
sinfo->failures++;
Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.h
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.h 2006-01-31 10:39:45 UTC (rev 13257)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.h 2006-01-31 11:16:43 UTC (rev 13258)
@@ -79,7 +79,9 @@
const struct ldb_val *val);
void ltdb_search_dn1_free(struct ldb_module *module, struct ldb_message *msg);
int ltdb_search_dn1(struct ldb_module *module, const struct ldb_dn *dn, struct ldb_message *msg);
-int ltdb_add_attr_results(struct ldb_module *module, struct ldb_message *msg,
+int ltdb_add_attr_results(struct ldb_module *module,
+ TALLOC_CTX *mem_ctx,
+ struct ldb_message *msg,
const char * const attrs[],
unsigned int *count,
struct ldb_message ***res);
More information about the samba-cvs
mailing list