summaryrefslogtreecommitdiff
path: root/source4/dsdb/schema
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-02-13 12:59:43 +1100
committerAndrew Tridgell <tridge@samba.org>2010-02-13 22:36:12 +1100
commit5549190b37a2bfc01f5cbff89da47b7ca4bd84fa (patch)
treebf93d3c120e6c176cee7574f04e866a447c29814 /source4/dsdb/schema
parent1373e748aa53fbd3afe4d2377208257d42628d86 (diff)
downloadsamba-5549190b37a2bfc01f5cbff89da47b7ca4bd84fa.tar.gz
samba-5549190b37a2bfc01f5cbff89da47b7ca4bd84fa.tar.bz2
samba-5549190b37a2bfc01f5cbff89da47b7ca4bd84fa.zip
s4-dsdb: use TYPESAFE_QSORT() in dsdb code
Diffstat (limited to 'source4/dsdb/schema')
-rw-r--r--source4/dsdb/schema/schema_query.c10
-rw-r--r--source4/dsdb/schema/schema_set.c25
2 files changed, 12 insertions, 23 deletions
diff --git a/source4/dsdb/schema/schema_query.c b/source4/dsdb/schema/schema_query.c
index 4e11e50c17..ff54488251 100644
--- a/source4/dsdb/schema/schema_query.c
+++ b/source4/dsdb/schema/schema_query.c
@@ -23,6 +23,7 @@
#include "includes.h"
#include "dsdb/samdb/samdb.h"
#include "lib/util/binsearch.h"
+#include "lib/util/tsort.h"
static const char **dsdb_full_attribute_list_internal(TALLOC_CTX *mem_ctx,
const struct dsdb_schema *schema,
@@ -379,11 +380,8 @@ static const char **dsdb_full_attribute_list_internal_el(TALLOC_CTX *mem_ctx,
return attr_list;
}
-static int qsort_string(const void *v1,
- const void *v2)
+static int qsort_string(const char **s1, const char **s2)
{
- char * const *s1 = v1;
- char * const *s2 = v2;
return strcasecmp(*s1, *s2);
}
@@ -394,9 +392,7 @@ static const char **dedup_attr_list(const char **attr_list)
/* Remove duplicates */
if (new_len > 1) {
int i;
- qsort(attr_list, new_len,
- sizeof(*attr_list),
- (comparison_fn_t)qsort_string);
+ TYPESAFE_QSORT(attr_list, new_len, qsort_string);
for (i=1 ; i < new_len; i++) {
const char **val1 = &attr_list[i-1];
diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c
index f59fc32696..99b26f6b9d 100644
--- a/source4/dsdb/schema/schema_set.c
+++ b/source4/dsdb/schema/schema_set.c
@@ -27,6 +27,7 @@
#include "param/param.h"
#include "librpc/ndr/libndr.h"
#include "librpc/gen_ndr/ndr_misc.h"
+#include "lib/util/tsort.h"
/*
override the name to attribute handler function
@@ -259,14 +260,10 @@ static int dsdb_setup_sorted_accessors(struct ldb_context *ldb,
}
/* sort the arrays */
- qsort(schema->classes_by_lDAPDisplayName, schema->num_classes,
- sizeof(struct dsdb_class *), QSORT_CAST dsdb_compare_class_by_lDAPDisplayName);
- qsort(schema->classes_by_governsID_id, schema->num_classes,
- sizeof(struct dsdb_class *), QSORT_CAST dsdb_compare_class_by_governsID_id);
- qsort(schema->classes_by_governsID_oid, schema->num_classes,
- sizeof(struct dsdb_class *), QSORT_CAST dsdb_compare_class_by_governsID_oid);
- qsort(schema->classes_by_cn, schema->num_classes,
- sizeof(struct dsdb_class *), QSORT_CAST dsdb_compare_class_by_cn);
+ TYPESAFE_QSORT(schema->classes_by_lDAPDisplayName, schema->num_classes, dsdb_compare_class_by_lDAPDisplayName);
+ TYPESAFE_QSORT(schema->classes_by_governsID_id, schema->num_classes, dsdb_compare_class_by_governsID_id);
+ TYPESAFE_QSORT(schema->classes_by_governsID_oid, schema->num_classes, dsdb_compare_class_by_governsID_oid);
+ TYPESAFE_QSORT(schema->classes_by_cn, schema->num_classes, dsdb_compare_class_by_cn);
/* now build the attribute accessor arrays */
talloc_free(schema->attributes_by_lDAPDisplayName);
@@ -298,14 +295,10 @@ static int dsdb_setup_sorted_accessors(struct ldb_context *ldb,
}
/* sort the arrays */
- qsort(schema->attributes_by_lDAPDisplayName, schema->num_attributes,
- sizeof(struct dsdb_attribute *), QSORT_CAST dsdb_compare_attribute_by_lDAPDisplayName);
- qsort(schema->attributes_by_attributeID_id, schema->num_attributes,
- sizeof(struct dsdb_attribute *), QSORT_CAST dsdb_compare_attribute_by_attributeID_id);
- qsort(schema->attributes_by_attributeID_oid, schema->num_attributes,
- sizeof(struct dsdb_attribute *), QSORT_CAST dsdb_compare_attribute_by_attributeID_oid);
- qsort(schema->attributes_by_linkID, schema->num_attributes,
- sizeof(struct dsdb_attribute *), QSORT_CAST dsdb_compare_attribute_by_linkID);
+ TYPESAFE_QSORT(schema->attributes_by_lDAPDisplayName, schema->num_attributes, dsdb_compare_attribute_by_lDAPDisplayName);
+ TYPESAFE_QSORT(schema->attributes_by_attributeID_id, schema->num_attributes, dsdb_compare_attribute_by_attributeID_id);
+ TYPESAFE_QSORT(schema->attributes_by_attributeID_oid, schema->num_attributes, dsdb_compare_attribute_by_attributeID_oid);
+ TYPESAFE_QSORT(schema->attributes_by_linkID, schema->num_attributes, dsdb_compare_attribute_by_linkID);
return LDB_SUCCESS;