41,6 → 41,8 |
* This is only a wrapper that takes care of memory allocations for storing |
* the pivot and temporary elements for generic quicksort algorithm. |
* |
* This function _can_ sleep |
* |
* @param data Pointer to data to be sorted. |
* @param n Number of elements to be sorted. |
* @param e_size Size of one element. |
55,13 → 57,9 |
void * pivot = buf_pivot; |
|
if (e_size > EBUFSIZE) { |
pivot = (void *) malloc(e_size); |
tmp = (void *) malloc(e_size); |
|
if (!tmp || !pivot) { |
panic("Cannot allocate memory\n"); |
pivot = (void *) malloc(e_size, 0); |
tmp = (void *) malloc(e_size, 0); |
} |
} |
|
_qsort(data, n, e_size, cmp, tmp, pivot); |
|
126,12 → 124,8 |
void * slot = buf_slot; |
|
if (e_size > EBUFSIZE) { |
slot = (void *) malloc(e_size); |
|
if (!slot) { |
panic("Cannot allocate memory\n"); |
slot = (void *) malloc(e_size, 0); |
} |
} |
|
_bubblesort(data, n, e_size, cmp, slot); |
|