github.com/ethereum/go-ethereum@v1.16.1/crypto/secp256k1/libsecp256k1/src/hsort.h (about)

     1  /***********************************************************************
     2   * Copyright (c) 2021 Russell O'Connor, Jonas Nick                     *
     3   * Distributed under the MIT software license, see the accompanying    *
     4   * file COPYING or https://www.opensource.org/licenses/mit-license.php.*
     5   ***********************************************************************/
     6  
     7  #ifndef SECP256K1_HSORT_H
     8  #define SECP256K1_HSORT_H
     9  
    10  #include <stddef.h>
    11  #include <string.h>
    12  
    13  /* In-place, iterative heapsort with an interface matching glibc's qsort_r. This
    14   * is preferred over standard library implementations because they generally
    15   * make no guarantee about being fast for malicious inputs.
    16   * Remember that heapsort is unstable.
    17   *
    18   * In/Out: ptr: pointer to the array to sort. The contents of the array are
    19   *              sorted in ascending order according to the comparison function.
    20   * In:   count: number of elements in the array.
    21   *        size: size in bytes of each element.
    22   *         cmp: pointer to a comparison function that is called with two
    23   *              arguments that point to the objects being compared. The cmp_data
    24   *              argument of secp256k1_hsort is passed as third argument. The
    25   *              function must return an integer less than, equal to, or greater
    26   *              than zero if the first argument is considered to be respectively
    27   *              less than, equal to, or greater than the second.
    28   *    cmp_data: pointer passed as third argument to cmp.
    29   */
    30  static void secp256k1_hsort(void *ptr, size_t count, size_t size,
    31                              int (*cmp)(const void *, const void *, void *),
    32                              void *cmp_data);
    33  #endif