Fix latest covs

This commit is contained in:
pancake 2016-10-26 11:01:42 +02:00
parent f19b34edf8
commit 8b8151d12e
2 changed files with 13 additions and 13 deletions

View File

@ -269,6 +269,8 @@ static int cmp (const void *a, const void *b) {
free (db);
return ret;
}
free (da);
free (db);
return strcmp (a, b);
}

View File

@ -501,8 +501,7 @@ static RListIter * _merge_sort(RListIter *head, RListComparator cmp) {
}
R_API void r_list_merge_sort(RList *list, RListComparator cmp) {
if (!list->sorted) {
if (list && list->head && cmp) {
if (list && !list->sorted && list->head && cmp) {
RListIter *iter;
list->head = _merge_sort (list->head, cmp);
//update tail reference
@ -514,13 +513,12 @@ R_API void r_list_merge_sort(RList *list, RListComparator cmp) {
}
list->sorted = true;
}
}
R_API void r_list_insertion_sort(RList *list, RListComparator cmp) {
if (!list->sorted) {
if (list && !list->sorted) {
RListIter *it;
RListIter *it2;
if (list && cmp) {
if (cmp) {
for (it = list->head; it && it->data; it = it->n) {
for (it2 = it->n; it2 && it2->data; it2 = it2->n) {
if (cmp (it->data, it2->data) > 0) {