safec
3.0
Safe C Library - ISO TR24731 Bounds Checking Interface
|
Macros | |
#define | ntz(x) a_ctz_l((x)) |
Typedefs | |
typedef unsigned long | uint64_t |
typedef int(* | cmpfun) (const void *, const void *, void *) |
The qsort_s function sorts the given array pointed to by base in ascending order. More... | |
Functions | |
static int | a_ctz_64 (uint64_t x) |
static int | a_ctz_l (unsigned long x) |
static int | pntz (size_t p[2]) |
static void | cycle (size_t width, unsigned char *ar[], int n) |
static void | shl (size_t p[2], int n) |
static void | shr (size_t p[2], int n) |
static void | sift (unsigned char *head, size_t width, cmpfun cmp, int pshift, size_t lp[], void *ctx) |
static void | trinkle (unsigned char *head, size_t width, cmpfun cmp, size_t pp[2], int pshift, int trusty, size_t lp[], void *ctx) |
static void | qsort_musl (void *base, size_t nel, size_t width, cmpfun cmp, void *ctx) |
EXPORT errno_t | qsort_s (void *base, rsize_t nmemb, rsize_t size, int(*compar)(const void *k, const void *y, void *context), void *context) |
Variables | |
static const char | debruijn32 [32] |
#define ntz | ( | x | ) | a_ctz_l((x)) |
typedef unsigned long uint64_t |
typedef int(* cmpfun) (const void *, const void *, void *) |
The qsort_s
function sorts the given array pointed to by base in ascending order.
The array contains nmemb elements of size bytes. Function pointed to by compar is used for object comparison.
[in] | base | pointer to the array to sort |
[in] | nmemb | number of elements in the array |
[in] | size | size of each element in the array in bytes |
[in] | compar | comparison function which returns a negative integer value if the first argument is less than the second, a positive integer value if the first argument is greater than the second and zero if the arguments are equal. key is passed as the first argument, an element from the array as the second. The signature of the comparison function should be equivalent to the following: int cmp(const void *a, const void *b, const void *context); The function must not modify the objects passed to it and must return consistent results when called for the same objects, regardless of their positions in the array. |
[in] | context | additional information (e.g., collating sequence), passed to compar as the third argument |
If comp indicates two elements as equivalent, their order in the resulting sorted array is unspecified.
qsort_s
does not treat arrays of zero size as a runtime constraint violation and instead returns successfully without altering the array (the other function that accepts arrays of zero size is bsearch_s
). Until qsort_s
, users of qsort
often used global variables to pass additional context to the comparison function.This function is available under windows with a different API, no return type, and is not available with safeclib.
EOK | when operation is successful |
-ESNULLP | when base/compar is NULL pointer and nmemb > 0 |
-ESLEMAX | when nmemb/size > RSIZE_MAX_MEM |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
static |
|
inlinestatic |
|
inlinestatic |
|
static |
|
static |
|
static |
EXPORT errno_t qsort_s | ( | void * | base, |
rsize_t | nmemb, | ||
rsize_t | size, | ||
int(*)(const void *k, const void *y, void *context) | compar, | ||
void * | context | ||
) |
|
static |