From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 50726138334 for ; Thu, 26 Sep 2019 14:06:52 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 699D4E087C; Thu, 26 Sep 2019 14:06:51 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 549C6E087C for ; Thu, 26 Sep 2019 14:06:51 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 60D2534B5DD for ; Thu, 26 Sep 2019 14:06:50 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 9DCF67FD for ; Thu, 26 Sep 2019 14:06:47 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1569505953.21a3d43cf7f43040132e9035c7b095a17b5a8bdd.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: libq/ X-VCS-Repository: proj/portage-utils X-VCS-Files: libq/xarray.c libq/xarray.h X-VCS-Directories: libq/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 21a3d43cf7f43040132e9035c7b095a17b5a8bdd X-VCS-Branch: master Date: Thu, 26 Sep 2019 14:06:47 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: b513aa10-92c4-43ca-bd6f-a5c69699ba67 X-Archives-Hash: 99eac2cfae7d284b1ec1b168bd76ff47 commit: 21a3d43cf7f43040132e9035c7b095a17b5a8bdd Author: Fabian Groffen gentoo org> AuthorDate: Thu Sep 26 13:52:33 2019 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Thu Sep 26 13:52:33 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=21a3d43c libq/xarray: add xarraysort function Signed-off-by: Fabian Groffen gentoo.org> libq/xarray.c | 5 +++++ libq/xarray.h | 1 + 2 files changed, 6 insertions(+) diff --git a/libq/xarray.c b/libq/xarray.c index a5cac49..49b478b 100644 --- a/libq/xarray.c +++ b/libq/xarray.c @@ -44,6 +44,11 @@ void *xarraypush(array_t *arr, const void *ele, size_t ele_len) return xarraypush_ptr(arr, xmemdup(ele, ele_len)); } +void xarraysort(array_t *arr, int (*compar)(const void *, const void *)) +{ + qsort(arr->eles, arr->num, sizeof(void *), compar); +} + void xarraydelete_ptr(array_t *arr, size_t elem) { arr->num--; diff --git a/libq/xarray.h b/libq/xarray.h index 71dfecb..6af0d39 100644 --- a/libq/xarray.h +++ b/libq/xarray.h @@ -40,6 +40,7 @@ typedef struct { void *xarrayget(array_t *arr, size_t idx); void *xarraypush_ptr(array_t *arr, void *ele); void *xarraypush(array_t *arr, const void *ele, size_t ele_len); +void xarraysort(array_t *arr, int (*compar)(const void *, const void *)); void xarraydelete_ptr(array_t *arr, size_t elem); void xarraydelete(array_t *arr, size_t elem); void xarrayfree_int(array_t *arr);