Context-free sorting function. More...
#include "config.h"
#include <stddef.h>
#include <stdlib.h>
#include "qsort_r.h"
#include <assert.h>
Go to the source code of this file.
Typedefs | |
typedef int(* | qsort_compar_t) (const void *a, const void *b) |
Prototype for generic comparison function, compatible with qsort() More... | |
Functions | |
static int | relay_compar (const void *a, const void *b) |
Shim to pass context through to real comparator. More... | |
void | mutt_qsort_r (void *base, size_t nmemb, size_t size, qsort_r_compar_t compar, void *arg) |
Sort an array, where the comparator has access to opaque data rather than requiring global variables. More... | |
Variables | |
static qsort_r_compar_t | global_compar = NULL |
Original comparator in fallback implementation. More... | |
static void * | global_data = NULL |
Original opaque data in fallback implementation. More... | |
Context-free sorting function.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file qsort_r.c.
typedef int(* qsort_compar_t) (const void *a, const void *b) |
|
static |
Shim to pass context through to real comparator.
a | First item to be compared |
b | Second item to be compared |
<0 | a sorts before b |
0 | a and b sort equally (sort stability not guaranteed) |
>0 | a sorts after b |
Definition at line 59 of file qsort_r.c.
void mutt_qsort_r | ( | void * | base, |
size_t | nmemb, | ||
size_t | size, | ||
qsort_r_compar_t | compar, | ||
void * | arg | ||
) |
Sort an array, where the comparator has access to opaque data rather than requiring global variables.
base | Start of the array to be sorted |
nmemb | Number of elements in the array |
size | Size of each array element |
compar | Comparison function, return <0/0/>0 to compare two elements |
arg | Opaque argument to pass to compar |
Definition at line 76 of file qsort_r.c.
|
static |