s4:descriptor LDB module - remove a bit pointless memory context
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Sat, 6 Nov 2010 21:39:40 +0000 (22:39 +0100)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Sun, 7 Nov 2010 09:27:24 +0000 (10:27 +0100)
For only one operation we do not need an additional "mem_ctx". "ac" should be
enough (see for example the samldb LDB module).

source4/dsdb/samdb/ldb_modules/descriptor.c

index 5b74c9c6560e6285a8ffe41928f69ec5039dc189..935069a00d7061351ee68cb2f7adfd970bfccfbd 100644 (file)
@@ -672,7 +672,6 @@ static int descriptor_do_add(struct descriptor_context *ac)
        struct ldb_request *add_req;
        struct ldb_message_element *objectclass_element, *sd_element = NULL;
        struct ldb_message *msg;
-       TALLOC_CTX *mem_ctx;
        int ret;
        DATA_BLOB *sd;
        const struct dsdb_class *objectclass;
@@ -682,11 +681,6 @@ static int descriptor_do_add(struct descriptor_context *ac)
        ldb = ldb_module_get_ctx(ac->module);
        schema = dsdb_get_schema(ldb, ac);
 
-       mem_ctx = talloc_new(ac);
-       if (mem_ctx == NULL) {
-               return ldb_module_oom(ac->module);
-       }
-
        switch (ac->req->operation) {
        case LDB_ADD:
                msg = ldb_msg_copy_shallow(ac, ac->req->op.add.message);
@@ -738,7 +732,7 @@ static int descriptor_do_add(struct descriptor_context *ac)
                /* Get the parent descriptor and the one provided. If not
                 * provided, get the default. Convert it to a security
                 * descriptor and calculate the permissions. */
-               sd = get_new_descriptor(ac->module, msg->dn, mem_ctx, objectclass,
+               sd = get_new_descriptor(ac->module, msg->dn, ac, objectclass,
                                        ac->parentsd_val, ac->sd_val, NULL, 0);
                if (ac->sd_val) {
                        ldb_msg_remove_attr(msg, "nTSecurityDescriptor");
@@ -751,8 +745,6 @@ static int descriptor_do_add(struct descriptor_context *ac)
                        }
                }
 
-               talloc_free(mem_ctx);
-
                ret = ldb_build_add_req(&add_req, ldb, ac,
                                        msg,
                                        ac->req->controls,