rcutils  master
C API providing common utilities and data structures.
Functions
qsort.h File Reference
#include "rcutils/macros.h"
#include "rcutils/types/rcutils_ret.h"
#include "rcutils/visibility_control.h"
Include dependency graph for qsort.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

rcutils_ret_t rcutils_qsort (void *ptr, size_t count, size_t size, int(*comp)(const void *, const void *))
 Interface to qsort with rcutils-style argument validation. More...
 

Function Documentation

◆ rcutils_qsort()

rcutils_ret_t rcutils_qsort ( void *  ptr,
size_t  count,
size_t  size,
int(*)(const void *, const void *)  comp 
)

Interface to qsort with rcutils-style argument validation.

This function changes the order of the elements in the array so that they are in ascending order according to the given comparison function.

This function is thread-safe.

Parameters
[in,out]ptrobject whose elements should be sorted.
[in]countnumber of elements present in the object.
[in]sizesize of each element, in bytes.
[in]compfunction used to compare two elements.
Returns
RCUTILS_RET_OK if successful, or
RCUTILS_RET_INVALID_ARGUMENT for invalid arguments, or
RCUTILS_RET_ERROR if an unknown error occurs.