Check of count or size is 0 in heapsort
This commit is contained in:
+9
-1
@@ -29,9 +29,17 @@ void
|
||||
uc_heapsort(void *base_, size_t count, size_t width,
|
||||
uc_hs_cmp cmp, uc_hs_swp swap, void *cookie)
|
||||
{
|
||||
int start = count / 2 - 1, end = count - 1;
|
||||
long start;
|
||||
long end;
|
||||
unsigned char *base = base_;
|
||||
|
||||
if (count == 0 || width == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
start = count / 2 - 1,
|
||||
end = count - 1;
|
||||
|
||||
while (start >= 0) {
|
||||
uc_sift(base, start, count, width, cmp, swap, cookie);
|
||||
start--;
|
||||
|
||||
Reference in New Issue
Block a user