chiark / gitweb /
basic/strv: use existing qsort_safe() helper
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 10 Jul 2017 18:55:14 +0000 (14:55 -0400)
committerSven Eden <yamakuzure@gmx.net>
Tue, 25 Jul 2017 07:48:11 +0000 (09:48 +0200)
strv_sort() predates qsort_safe(), but we can convert it to it to
save a few lines.

src/basic/strv.c

index c2defbe970149cc8a0423f70362e44ce4f691d68..f0c764b17ae16dc74cd53a485d8dcf78f21bc57c 100644 (file)
@@ -782,11 +782,7 @@ static int str_compare(const void *_a, const void *_b) {
 }
 
 char **strv_sort(char **l) {
-
-        if (strv_isempty(l))
-                return l;
-
-        qsort(l, strv_length(l), sizeof(char*), str_compare);
+        qsort_safe(l, strv_length(l), sizeof(char*), str_compare);
         return l;
 }