Graphviz 13.0.0~dev.20250523.0001
Loading...
Searching...
No Matches
sort.h File Reference

qsort with carried along context More...

#include <assert.h>
#include <stdlib.h>
Include dependency graph for sort.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static int gv_sort_compar_wrapper (const void *a, const void *b)
 
static void gv_sort (void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *, void *), void *arg)
 qsort with an extra state parameter, ala qsort_r
 

Variables

static _Thread_local int(* gv_sort_compar )(const void *, const void *, void *)
 
static _Thread_local void * gv_sort_arg
 

Detailed Description

The non-standard qsort_r, Windows’ qsort_s, and C11’s qsort_s provide a qsort alternative with an extra state parameter. Unfortunately none of these are easily usable portably in Graphviz. This header implements an alternative that hopefully is.

Definition in file sort.h.

Function Documentation

◆ gv_sort()

static void gv_sort ( void *  base,
size_t  nmemb,
size_t  size,
int(*)(const void *, const void *, void *)  compar,
void *  arg 
)
inlinestatic

Definition at line 24 of file sort.h.

References gv_sort_arg, gv_sort_compar, gv_sort_compar_wrapper(), and NULL.

Referenced by arrayRects(), find_closest_pairs(), quicksort_place(), quicksort_place(), and quicksort_placef().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gv_sort_compar_wrapper()

static int gv_sort_compar_wrapper ( const void *  a,
const void *  b 
)
inlinestatic

Definition at line 18 of file sort.h.

References gv_sort_arg, gv_sort_compar, and NULL.

Referenced by gv_sort().

Here is the caller graph for this function:

Variable Documentation

◆ gv_sort_arg

_Thread_local void* gv_sort_arg
static

Definition at line 16 of file sort.h.

Referenced by gv_sort(), and gv_sort_compar_wrapper().

◆ gv_sort_compar

_Thread_local int(* gv_sort_compar) (const void *, const void *, void *) ( const void *  ,
const void *  ,
void *   
)
static

Definition at line 15 of file sort.h.

Referenced by gv_sort(), and gv_sort_compar_wrapper().