lists now sort on heap to prevent stack overflows

Fri, 12 Oct 2012 12:12:59 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 12 Oct 2012 12:12:59 +0200
changeset 73
f15c7d6aebb9
parent 72
bb3eae81aae8
child 74
dc8bade7f2a3

lists now sort on heap to prevent stack overflows

ucx/dlist.c file | annotate | diff | comparison | revisions
ucx/list.c file | annotate | diff | comparison | revisions
--- a/ucx/dlist.c	Fri Oct 12 12:09:00 2012 +0200
+++ b/ucx/dlist.c	Fri Oct 12 12:12:59 2012 +0200
@@ -117,7 +117,8 @@
 UcxDlist *ucx_dlist_sort_merge(int length,
         UcxDlist* restrict ls, UcxDlist* restrict le, UcxDlist* restrict re,
         cmp_func fnc, void* data) {
-    ucx_dynarray_new(UcxDlist*, sorted, length);
+
+    UcxDlist** sorted = (UcxDlist**) malloc(sizeof(UcxDlist*)*length);
     UcxDlist *rc, *lc;
 
     lc = ls; rc = le;
@@ -152,7 +153,7 @@
     sorted[length-1]->next = NULL;
 
     UcxDlist *ret = sorted[0];
-    ucx_dynarray_free(sorted);
+    free(sorted);
     return ret;
 }
 
--- a/ucx/list.c	Fri Oct 12 12:09:00 2012 +0200
+++ b/ucx/list.c	Fri Oct 12 12:12:59 2012 +0200
@@ -114,7 +114,7 @@
         UcxList* restrict ls, UcxList* restrict le, UcxList* restrict re,
         cmp_func fnc, void* data) {
 
-    ucx_dynarray_new(UcxList*, sorted, length);
+    UcxList** sorted = (UcxList**) malloc(sizeof(UcxList*)*length);
     UcxList *rc, *lc;
 
     lc = ls; rc = le;
@@ -147,7 +147,7 @@
     sorted[length-1]->next = NULL;
 
     UcxList *ret = sorted[0];
-    ucx_dynarray_free(sorted);
+    free(sorted);
     return ret;
 }
 

mercurial