s4:objectclass LDB module - "objectclass_add" - small optimisation
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Wed, 12 Oct 2011 07:29:08 +0000 (09:29 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Thu, 27 Oct 2011 16:52:29 +0000 (18:52 +0200)
This saves us from doing one "ldb_msg_find_element".

Reviewed-by: abartlet
source4/dsdb/samdb/ldb_modules/objectclass.c

index 5c89371216386f26a38ac8f0bd0a94d798febe3e..6e087b989708b3b9272fe0b44073339cc69417cc 100644 (file)
@@ -555,7 +555,8 @@ static int objectclass_do_add(struct oc_context *ac)
 
                /* We must completely replace the existing objectClass entry,
                 * because we need it sorted. */
-               ret = ldb_msg_add_empty(msg, "objectClass", 0, NULL);
+               ret = ldb_msg_add_empty(msg, "objectClass", 0,
+                                       &objectclass_element);
                if (ret != LDB_SUCCESS) {
                        talloc_free(mem_ctx);
                        return ret;
@@ -577,9 +578,6 @@ static int objectclass_do_add(struct oc_context *ac)
 
                talloc_free(mem_ctx);
 
-               /* Retrive the message again so get_last_structural_class works */
-               objectclass_element = ldb_msg_find_element(msg, "objectClass");
-
                /* Make sure its valid to add an object of this type */
                objectclass = get_last_structural_class(ac->schema,
                                                        objectclass_element, ac->req);