Check of count or size is 0 in heapsort

This commit is contained in:
Nils O. Selåsdal
2013-12-03 14:29:57 +01:00
parent 70fb352656
commit 4caf2573fb
2 changed files with 38 additions and 2 deletions
+9 -1
View File
@@ -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--;