diff options
author | Simo Sorce <idra@samba.org> | 2006-03-08 01:01:14 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:52:36 -0500 |
commit | 82da2d401e54d0b3124b727fab755d94dd5402d4 (patch) | |
tree | 96670e28213628ea78e1d0bec751a24d17ec61ae /source4/lib/ldb/tools | |
parent | 257598424e63c2cfa118b5ea84b7dc719d1dc5aa (diff) | |
download | samba-82da2d401e54d0b3124b727fab755d94dd5402d4.tar.gz samba-82da2d401e54d0b3124b727fab755d94dd5402d4.tar.bz2 samba-82da2d401e54d0b3124b727fab755d94dd5402d4.zip |
r13998: From now on ldb_request() will require an alloced request
By freeing the request you will be sure everything down the path get freed.
this also means you have to steal the results if you want to keep them :)
simo.
(This used to be commit e8075e6a062ce5edb84485e45d0b841c2ee2af7d)
Diffstat (limited to 'source4/lib/ldb/tools')
-rw-r--r-- | source4/lib/ldb/tools/ldbsearch.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c index fbf32c0777..77f54fee65 100644 --- a/source4/lib/ldb/tools/ldbsearch.c +++ b/source4/lib/ldb/tools/ldbsearch.c @@ -68,33 +68,34 @@ static int do_search(struct ldb_context *ldb, int loop = 0; int total = 0; int refs = 0; - struct ldb_request req; + struct ldb_request *req; struct ldb_result *result = NULL; - req.operation = LDB_REQ_SEARCH; - req.op.search.base = basedn; - req.op.search.scope = options->scope; - req.op.search.tree = ldb_parse_tree(ldb, expression); - if (req.op.search.tree == NULL) return -1; - req.op.search.attrs = attrs; - req.op.search.res = NULL; - req.controls = parse_controls(ldb, options->controls); - if (options->controls != NULL && req.controls == NULL) return -1; - req.creds = NULL; + req = talloc(ldb, struct ldb_request); + req->operation = LDB_REQ_SEARCH; + req->op.search.base = basedn; + req->op.search.scope = options->scope; + req->op.search.tree = ldb_parse_tree(ldb, expression); + if (req->op.search.tree == NULL) return -1; + req->op.search.attrs = attrs; + req->op.search.res = NULL; + req->controls = parse_controls(ldb, options->controls); + if (options->controls != NULL && req->controls == NULL) return -1; + req->creds = NULL; do { loop = 0; - ret = ldb_request(ldb, &req); + ret = ldb_request(ldb, req); if (ret != LDB_SUCCESS) { printf("search failed - %s\n", ldb_errstring(ldb)); - if (req.op.search.res && req.op.search.res->controls) { - handle_controls_reply(req.op.search.res->controls, req.controls); + if (req->op.search.res && req->op.search.res->controls) { + handle_controls_reply(req->op.search.res->controls, req->controls); } return -1; } - result = req.op.search.res; + result = req->op.search.res; if (options->sorted) { ldb_qsort(result->msgs, result->count, sizeof(struct ldb_message *), @@ -127,7 +128,7 @@ static int do_search(struct ldb_context *ldb, } if (result->controls) { - if (handle_controls_reply(result->controls, req.controls) == 1) + if (handle_controls_reply(result->controls, req->controls) == 1) loop = 1; } @@ -139,7 +140,7 @@ static int do_search(struct ldb_context *ldb, } } - req.op.search.res = NULL; + req->op.search.res = NULL; } while(loop); |