From 7dd80e872dacacf95d16b0460119296275a18ab0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 13 Jan 2007 15:03:00 +0000 Subject: r20731: we need the complex memmove() handling for removing an attribute only in one place metze (This used to be commit dfdfdd6cefeac2974a4b3425a49e3dd93ad7e952) --- source4/lib/ldb/common/ldb_msg.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c index bed3647d3a..077446f8ca 100644 --- a/source4/lib/ldb/common/ldb_msg.c +++ b/source4/lib/ldb/common/ldb_msg.c @@ -728,22 +728,6 @@ int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *rep return ldb_msg_rename_attr(msg, attr, replace); } - -/* - remove the specified attribute in a search result -*/ -void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr) -{ - struct ldb_message_element *el = ldb_msg_find_element(msg, attr); - if (el) { - int n = (el - msg->elements); - if (n != msg->num_elements-1) { - memmove(el, el+1, ((msg->num_elements-1) - n)*sizeof(*el)); - } - msg->num_elements--; - } -} - /* remove the specified element in a search result */ @@ -756,6 +740,18 @@ void ldb_msg_remove_element(struct ldb_message *msg, struct ldb_message_element msg->num_elements--; } + +/* + remove the specified attribute in a search result +*/ +void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr) +{ + struct ldb_message_element *el = ldb_msg_find_element(msg, attr); + if (el) { + ldb_msg_remove_element(msg, el); + } +} + /* return a LDAP formatted GeneralizedTime string */ -- cgit