diff options
author | Stefan Metzmacher <metze@samba.org> | 2007-01-13 15:03:00 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:40:33 -0500 |
commit | 7dd80e872dacacf95d16b0460119296275a18ab0 (patch) | |
tree | b09a80b20149dc575aec7a6b4bfca869964e2de0 /source4/lib/ldb | |
parent | bc4af8dd5ef900f0ab46f4ddaf91e33772a3e029 (diff) | |
download | samba-7dd80e872dacacf95d16b0460119296275a18ab0.tar.gz samba-7dd80e872dacacf95d16b0460119296275a18ab0.tar.bz2 samba-7dd80e872dacacf95d16b0460119296275a18ab0.zip |
r20731: we need the complex memmove() handling for removing an attribute only in one place
metze
(This used to be commit dfdfdd6cefeac2974a4b3425a49e3dd93ad7e952)
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r-- | source4/lib/ldb/common/ldb_msg.c | 28 |
1 files 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 */ |