From 65b967a706bb4ee2da1d4211c31c91d31a81e8f1 Mon Sep 17 00:00:00 2001 From: Kamen Mazdrashki Date: Fri, 16 Jul 2010 14:23:24 +0300 Subject: s4-ldb: Implement ldb_msg_difference() function to accept a memory context from client Old implementation from ldb_msg_diff() was moved into this this function but with changed interface so that a memory context may be passed. ldb_msg_diff() function is now based on ldb_msg_difference(), which fixes a hidden leak - internal ldb_msg object (returned from ldb_msg_canonicalize) wasn't freed and stays attached to ldb_context for the connection lifetime. Signed-off-by: Andrew Bartlett --- source4/lib/ldb/include/ldb.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 039f70895a..667c91b34d 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1859,6 +1859,26 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, struct ldb_message *msg1, struct ldb_message *msg2); +/** + * return a ldb_message representing the differences between msg1 and msg2. + * If you then use this in a ldb_modify() call, + * it can be used to save edits to a message + * + * Result message is constructed as follows: + * - LDB_FLAG_MOD_ADD - elements found only in msg2 + * - LDB_FLAG_MOD_REPLACE - elements in msg2 that have + * different value in msg1 + * Value for msg2 element is used + * - LDB_FLAG_MOD_DELETE - elements found only in msg2 + * + * @return LDB_SUCCESS or LDB_ERR_OPERATIONS_ERROR + */ +int ldb_msg_difference(struct ldb_context *ldb, + TALLOC_CTX *mem_ctx, + struct ldb_message *msg1, + struct ldb_message *msg2, + struct ldb_message **_msg_out); + /** Tries to find a certain string attribute in a message -- cgit