Author: metze
Date: 2006-10-09 09:56:13 +0000 (Mon, 09 Oct 2006)
New Revision: 19196

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

Log:
merge from samba3:

pass always a mem_ctx to functions and a ldb_context where needed

metze
Modified:
   branches/SAMBA_4_0/source/lib/ldb/common/attrib_handlers.c
   branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c
   branches/SAMBA_4_0/source/lib/ldb/common/ldb_match.c
   branches/SAMBA_4_0/source/lib/ldb/common/ldb_modules.c
   branches/SAMBA_4_0/source/lib/ldb/include/ldb.h
   branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/common/attrib_handlers.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/common/attrib_handlers.c  2006-10-09 
09:12:57 UTC (rev 19195)
+++ branches/SAMBA_4_0/source/lib/ldb/common/attrib_handlers.c  2006-10-09 
09:56:13 UTC (rev 19196)
@@ -230,7 +230,7 @@
        out->length = 0;
        out->data = NULL;
 
-       dn = ldb_dn_explode_casefold(ldb, (char *)in->data);
+       dn = ldb_dn_explode_casefold(ldb, mem_ctx, (char *)in->data);
        if (dn == NULL) {
                return -1;
        }
@@ -258,10 +258,10 @@
        struct ldb_dn *dn1 = NULL, *dn2 = NULL;
        int ret;
 
-       dn1 = ldb_dn_explode_casefold(mem_ctx, (char *)v1->data);
+       dn1 = ldb_dn_explode_casefold(ldb, mem_ctx, (char *)v1->data);
        if (dn1 == NULL) return -1;
 
-       dn2 = ldb_dn_explode_casefold(mem_ctx, (char *)v2->data);
+       dn2 = ldb_dn_explode_casefold(ldb, mem_ctx, (char *)v2->data);
        if (dn2 == NULL) {
                talloc_free(dn1);
                return -1;

Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c   2006-10-09 09:12:57 UTC 
(rev 19195)
+++ branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c   2006-10-09 09:56:13 UTC 
(rev 19196)
@@ -554,10 +554,10 @@
 
        if (dn0 == NULL || dn1 == NULL) return dn1 - dn0;
 
-       edn0 = ldb_dn_explode_casefold(ldb, dn0);
+       edn0 = ldb_dn_explode_casefold(ldb, ldb, dn0);
        if (edn0 == NULL) return 1;
 
-       edn1 = ldb_dn_explode_casefold(ldb, dn1);
+       edn1 = ldb_dn_explode_casefold(ldb, ldb, dn1);
        if (edn1 == NULL) {
                talloc_free(edn0);
                return -1;
@@ -575,14 +575,14 @@
   casefold a dn. We need to casefold the attribute names, and canonicalize 
   attribute values of case insensitive attributes.
 */
-struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, const struct ldb_dn 
*edn)
+struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, void *mem_ctx, const 
struct ldb_dn *edn)
 {
        struct ldb_dn *cedn;
-       int i;
+       int i, ret;
 
        if (edn == NULL) return NULL;
 
-       cedn = ldb_dn_new(ldb);
+       cedn = ldb_dn_new(mem_ctx);
        if (!cedn) {
                return NULL;
        }
@@ -599,14 +599,17 @@
                const struct ldb_attrib_handler *h;
 
                memset(&dc, 0, sizeof(dc));
-               dc.name = ldb_attr_casefold(cedn, edn->components[i].name);
+               dc.name = ldb_attr_casefold(cedn->components, 
edn->components[i].name);
                if (!dc.name) {
                        talloc_free(cedn);
                        return NULL;
                }
 
                h = ldb_attrib_handler(ldb, dc.name);
-               if (h->canonicalise_fn(ldb, cedn, &(edn->components[i].value), 
&(dc.value)) != 0) {
+               ret = h->canonicalise_fn(ldb, cedn->components,
+                                        &(edn->components[i].value),
+                                        &(dc.value));
+               if (ret != 0) {
                        talloc_free(cedn);
                        return NULL;
                }
@@ -617,7 +620,7 @@
        return cedn;
 }
 
-struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, const char *dn)
+struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, void *mem_ctx, 
const char *dn)
 {
        struct ldb_dn *edn, *cdn;
 
@@ -626,13 +629,13 @@
        edn = ldb_dn_explode(ldb, dn);
        if (edn == NULL) return NULL;
 
-       cdn = ldb_dn_casefold(ldb, edn);
+       cdn = ldb_dn_casefold(ldb, mem_ctx, edn);
        
        talloc_free(edn);
        return cdn;
 }
 
-char *ldb_dn_linearize_casefold(struct ldb_context *ldb, const struct ldb_dn 
*edn)
+char *ldb_dn_linearize_casefold(struct ldb_context *ldb, void *mem_ctx, const 
struct ldb_dn *edn)
 {
        struct ldb_dn *cdn;
        char *dn;
@@ -641,11 +644,11 @@
 
        /* Special DNs */
        if (ldb_dn_is_special(edn)) {
-               dn = talloc_strdup(ldb, (char *)edn->components[0].value.data);
+               dn = talloc_strdup(mem_ctx, (char 
*)edn->components[0].value.data);
                return dn;
        }
 
-       cdn = ldb_dn_casefold(ldb, edn);
+       cdn = ldb_dn_casefold(ldb, mem_ctx, edn);
        if (cdn == NULL) return NULL;
 
        dn = ldb_dn_linearize(ldb, cdn);

Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb_match.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/common/ldb_match.c        2006-10-09 
09:12:57 UTC (rev 19195)
+++ branches/SAMBA_4_0/source/lib/ldb/common/ldb_match.c        2006-10-09 
09:56:13 UTC (rev 19196)
@@ -149,7 +149,7 @@
        int ret;
 
        if (ldb_attr_dn(tree->u.equality.attr) == 0) {
-               valuedn = ldb_dn_explode_casefold(ldb, 
+               valuedn = ldb_dn_explode_casefold(ldb, ldb,
                                                  (char 
*)tree->u.equality.value.data);
                if (valuedn == NULL) {
                        return 0;

Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb_modules.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/common/ldb_modules.c      2006-10-09 
09:12:57 UTC (rev 19195)
+++ branches/SAMBA_4_0/source/lib/ldb/common/ldb_modules.c      2006-10-09 
09:56:13 UTC (rev 19196)
@@ -44,14 +44,13 @@
 #define LDB_MODULE_PREFIX      "modules:"
 #define LDB_MODULE_PREFIX_LEN  8
 
-static char *talloc_strdup_no_spaces(struct ldb_context *ldb, const char 
*string)
+static char *ldb_modules_strdup_no_spaces(TALLOC_CTX *mem_ctx, const char 
*string)
 {
        int i, len;
        char *trimmed;
 
-       trimmed = talloc_strdup(ldb, string);
+       trimmed = talloc_strdup(mem_ctx, string);
        if (!trimmed) {
-               ldb_debug(ldb, LDB_DEBUG_FATAL, "Out of Memory in 
talloc_strdup_trim_spaces()\n");
                return NULL;
        }
 
@@ -81,9 +80,9 @@
        int i;
 
        /* spaces not admitted */
-       modstr = talloc_strdup_no_spaces((struct ldb_context *)mem_ctx,
-                                        string);
+       modstr = ldb_modules_strdup_no_spaces(mem_ctx, string);
        if ( ! modstr) {
+               ldb_debug(ldb, LDB_DEBUG_FATAL, "Out of Memory in 
ldb_modules_strdup_no_spaces()\n");
                return NULL;
        }
 

Modified: branches/SAMBA_4_0/source/lib/ldb/include/ldb.h
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/include/ldb.h     2006-10-09 09:12:57 UTC 
(rev 19195)
+++ branches/SAMBA_4_0/source/lib/ldb/include/ldb.h     2006-10-09 09:56:13 UTC 
(rev 19196)
@@ -1146,11 +1146,11 @@
 struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn);
 struct ldb_dn *ldb_dn_explode_or_special(void *mem_ctx, const char *dn);
 char *ldb_dn_linearize(void *mem_ctx, const struct ldb_dn *edn);
-char *ldb_dn_linearize_casefold(struct ldb_context *ldb, const struct ldb_dn 
*edn);
+char *ldb_dn_linearize_casefold(struct ldb_context *ldb, void *mem_ctx, const 
struct ldb_dn *edn);
 int ldb_dn_compare_base(struct ldb_context *ldb, const struct ldb_dn *base, 
const struct ldb_dn *dn);
 int ldb_dn_compare(struct ldb_context *ldb, const struct ldb_dn *edn0, const 
struct ldb_dn *edn1);
-struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, const struct ldb_dn 
*edn);
-struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, const char 
*dn);
+struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, void *mem_ctx, const 
struct ldb_dn *edn);
+struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, void *mem_ctx, 
const char *dn);
 struct ldb_dn *ldb_dn_copy_partial(void *mem_ctx, const struct ldb_dn *dn, int 
num_el);
 struct ldb_dn *ldb_dn_copy(void *mem_ctx, const struct ldb_dn *dn);
 struct ldb_dn *ldb_dn_get_parent(void *mem_ctx, const struct ldb_dn *dn);

Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c 2006-10-09 09:12:57 UTC 
(rev 19195)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c 2006-10-09 09:56:13 UTC 
(rev 19196)
@@ -138,7 +138,7 @@
             the rest
        */
 
-       dn_folded = ldb_dn_linearize_casefold(ldb, dn);
+       dn_folded = ldb_dn_linearize_casefold(ldb, ldb, dn);
        if (!dn_folded) {
                goto failed;
        }

Reply via email to