summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mdw@samba.org>2011-03-10 09:28:30 +0100
committerMatthias Dieter Wallnöfer <mdw@samba.org>2011-03-10 11:12:04 +0100
commitb7ecc33ef9eae1a1ebe503a2d1d8c8ed21fb7ccf (patch)
tree4fa5701653e3df6d91251897f273150296fa69e0 /source4/lib/ldb/common
parent78c9eb1a06a696fc6ba85110a4f7d661bbb661d3 (diff)
downloadsamba-b7ecc33ef9eae1a1ebe503a2d1d8c8ed21fb7ccf.tar.gz
samba-b7ecc33ef9eae1a1ebe503a2d1d8c8ed21fb7ccf.tar.bz2
samba-b7ecc33ef9eae1a1ebe503a2d1d8c8ed21fb7ccf.zip
ldb:ldb_controls.c - "ldb_save_controls" - allow that "saver" can also be NULL
Suggested by Tridge
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r--source4/lib/ldb/common/ldb_controls.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/source4/lib/ldb/common/ldb_controls.c b/source4/lib/ldb/common/ldb_controls.c
index 8bf80f0dba..5a86bde211 100644
--- a/source4/lib/ldb/common/ldb_controls.c
+++ b/source4/lib/ldb/common/ldb_controls.c
@@ -72,18 +72,22 @@ struct ldb_control *ldb_reply_get_control(struct ldb_reply *rep, const char *oid
}
/*
- * Saves the current controls list into the "saver" and replace the one in "req"
- * with a new one excluding the "exclude" control (if it is NULL then the list
- * remains the same)
+ * Saves the current controls list into the "saver" (can also be NULL) and
+ * replace the one in "req" with a new one excluding the "exclude" control
+ * (if it is NULL then the list remains the same)
*
* Returns 0 on error.
*/
int ldb_save_controls(struct ldb_control *exclude, struct ldb_request *req, struct ldb_control ***saver)
{
- struct ldb_control **lcs;
+ struct ldb_control **lcs, **lcs_old;
unsigned int i, j;
- *saver = req->controls;
+ lcs_old = req->controls;
+ if (saver != NULL) {
+ *saver = lcs_old;
+ }
+
for (i = 0; req->controls && req->controls[i]; i++);
if (i == 0) {
req->controls = NULL;
@@ -95,9 +99,9 @@ int ldb_save_controls(struct ldb_control *exclude, struct ldb_request *req, stru
return 0;
}
- for (i = 0, j = 0; (*saver)[i]; i++) {
- if (exclude == (*saver)[i]) continue;
- lcs[j] = (*saver)[i];
+ for (i = 0, j = 0; lcs_old[i]; i++) {
+ if (exclude == lcs_old[i]) continue;
+ lcs[j] = lcs_old[i];
j++;
}
lcs[j] = NULL;