changeset 8816:a4a8f871be81

fix missing init in octave_sort<T>::sortrows
author Jaroslav Hajek <highegg@gmail.com>
date Thu, 19 Feb 2009 17:04:28 +0100
parents af907aeedbf4
children 03b7f618ab3d
files liboctave/oct-sort.cc
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/oct-sort.cc
+++ b/liboctave/oct-sort.cc
@@ -506,6 +506,7 @@
       delete [] ms->ia;
       ms->alloced = 0;
       ms->a = 0;
+      ms->ia = 0;
     }
 }
 
@@ -1700,6 +1701,17 @@
 octave_sort<T>::sort_rows (const T *data, octave_idx_type *idx,
                            octave_idx_type rows, octave_idx_type cols)
 {
+  /* Re-initialize the Mergestate as this might be the second time called */
+  if (ms)
+    {
+      ms->n = 0;
+      ms->min_gallop = MIN_GALLOP;
+    }
+  else
+    merge_init ();
+
+  merge_getmemi (1024);
+
 #ifdef INLINE_ASCENDING_SORT
   if (compare == ascending_compare)
     sort_rows (data, idx, rows, cols, std::less<T> ());