Author: metze
Date: 2006-12-12 16:56:53 +0000 (Tue, 12 Dec 2006)
New Revision: 20120

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20120

Log:
fix the talloc hierachy and make ildb a child of module

metze
Modified:
   branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c     2006-12-12 
16:40:57 UTC (rev 20119)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c     2006-12-12 
16:56:53 UTC (rev 20120)
@@ -54,6 +54,7 @@
 struct ildb_private {
        struct ldap_connection *ldap;
        struct ldb_context *ldb;
+       struct ldb_module *module;
 };
 
 struct ildb_context {
@@ -738,20 +739,32 @@
 */
 static int ildb_connect(struct ldb_context *ldb, const char *url, 
                        unsigned int flags, const char *options[],
-                       struct ldb_module **module)
+                       struct ldb_module **_module)
 {
-       struct ildb_private *ildb = NULL;
+       struct ldb_module *module;
+       struct ildb_private *ildb;
        NTSTATUS status;
        struct cli_credentials *creds;
 
-       ildb = talloc(ldb, struct ildb_private);
+       module = talloc(ldb, struct ldb_module);
+       if (!module) {
+               ldb_oom(ldb);
+               return -1;
+       }
+       talloc_set_name_const(module, "ldb_ildap backend");
+       module->ldb             = ldb;
+       module->prev            = module->next = NULL;
+       module->private_data    = NULL;
+       module->ops             = &ildb_ops;
+
+       ildb = talloc(module, struct ildb_private);
        if (!ildb) {
                ldb_oom(ldb);
                goto failed;
        }
-
-       ildb->ldb     = ldb;
-
+       module->private_data    = ildb;
+       ildb->ldb               = ldb;
+       ildb->module            = module;
        ildb->ldap = ldap4_new_connection(ildb, ldb_get_opaque(ldb, 
"EventContext"));
        if (!ildb->ldap) {
                ldb_oom(ldb);
@@ -769,19 +782,6 @@
                goto failed;
        }
 
-
-       *module = talloc(ldb, struct ldb_module);
-       if (!module) {
-               ldb_oom(ldb);
-               talloc_free(ildb);
-               return -1;
-       }
-       talloc_set_name_const(*module, "ldb_ildap backend");
-       (*module)->ldb = ldb;
-       (*module)->prev = (*module)->next = NULL;
-       (*module)->private_data = ildb;
-       (*module)->ops = &ildb_ops;
-
        /* caller can optionally setup credentials using the opaque token 
'credentials' */
        creds = talloc_get_type(ldb_get_opaque(ldb, "credentials"), struct 
cli_credentials);
        if (creds == NULL) {
@@ -811,10 +811,11 @@
                }
        }
 
+       *_module = module;
        return 0;
 
 failed:
-       talloc_free(ildb);
+       talloc_free(module);
        return -1;
 }
 

Reply via email to