Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
sort.c File Reference
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/sort.h>
#include <linux/slab.h>

Go to the source code of this file.

Functions

void sort (void *base, size_t num, size_t size, int(*cmp_func)(const void *, const void *), void(*swap_func)(void *, void *, int size))
 
 EXPORT_SYMBOL (sort)
 

Function Documentation

EXPORT_SYMBOL ( sort  )
void sort ( void base,
size_t  num,
size_t  size,
int(*)(const void *, const void *)  cmp_func,
void(*)(void *, void *, int size swap_func 
)

sort - sort an array of elements : pointer to data to sort : number of elements : size of each element : pointer to comparison function : pointer to swap function or NULL

This function does a heapsort on the given array. You may provide a swap_func function optimized to your element type.

Sorting time is O(n log n) both on average and worst-case. While qsort is about 20% faster on average, it suffers from exploitable O(n*n) worst-case behavior and extra memory requirements that make it less suitable for kernel use.

Definition at line 47 of file sort.c.