lib: use TYPESAFE_QSORT() in lib/ and libcli/
authorAndrew Tridgell <tridge@samba.org>
Sat, 13 Feb 2010 22:58:13 +0000 (09:58 +1100)
committerAndrew Tridgell <tridge@samba.org>
Sun, 14 Feb 2010 07:44:20 +0000 (18:44 +1100)
lib/util/util_strlist.c
libcli/security/secace.c

index 6d1a695987160b2bcb744579362b54270600ff99..af733d10ccfe41ae75677b0a29a8339ca6182b54 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "includes.h"
 #include "system/locale.h"
+#include "lib/util/tsort.h"
 
 #undef strcasecmp
 
@@ -393,7 +394,7 @@ _PUBLIC_ const char **str_list_unique(const char **list)
        }
        list2 = (const char **)talloc_memdup(list, list,
                                             sizeof(list[0])*(len+1));
-       qsort(list2, len, sizeof(list2[0]), QSORT_CAST list_cmp);
+       TYPESAFE_QSORT(list2, len, list_cmp);
        list[0] = list2[0];
        for (i=j=1;i<len;i++) {
                if (strcmp(list2[i], list[j-1]) != 0) {
index 7d87b1cd5eb4f122a393ea75500045d793af17bc..8a73a6ab94cea7109d26f4576c0954065598d452 100644 (file)
@@ -23,6 +23,7 @@
 #include "includes.h"
 #include "librpc/gen_ndr/ndr_security.h"
 #include "libcli/security/dom_sid.h"
+#include "lib/util/tsort.h"
 
 #define  SEC_ACE_HEADER_SIZE (2 * sizeof(uint8_t) + sizeof(uint16_t) + sizeof(uint32_t))
 
@@ -257,7 +258,7 @@ void dacl_sort_into_canonical_order(struct security_ace *srclist, unsigned int n
                return;
 
        /* Sort so that non-inherited ACE's come first. */
-       qsort( srclist, num_aces, sizeof(srclist[0]), QSORT_CAST nt_ace_inherit_comp);
+       TYPESAFE_QSORT(srclist, num_aces, nt_ace_inherit_comp);
 
        /* Find the boundary between non-inherited ACEs. */
        for (i = 0; i < num_aces; i++ ) {
@@ -270,12 +271,10 @@ void dacl_sort_into_canonical_order(struct security_ace *srclist, unsigned int n
        /* i now points at entry number of the first inherited ACE. */
 
        /* Sort the non-inherited ACEs. */
-       if (i)
-               qsort( srclist, i, sizeof(srclist[0]), QSORT_CAST nt_ace_canon_comp);
+       TYPESAFE_QSORT(srclist, i, nt_ace_canon_comp);
 
        /* Now sort the inherited ACEs. */
-       if (num_aces - i)
-               qsort( &srclist[i], num_aces - i, sizeof(srclist[0]), QSORT_CAST nt_ace_canon_comp);
+       TYPESAFE_QSORT(&srclist[i], num_aces - i, nt_ace_canon_comp);
 }