diff --git a/libinterp/corefcn/perms.cc b/libinterp/corefcn/perms.cc index f6d60cbdbf..c3922b06da 100644 --- a/libinterp/corefcn/perms.cc +++ b/libinterp/corefcn/perms.cc @@ -56,7 +56,7 @@ GetPerms (const Array &ar_in, bool uniq_v, bool do_sort = false) double nr = Factorial (m); // Setup index vector filled from 0..m-1 - int* myvidx = new int[m]; + OCTAVE_LOCAL_BUFFER (int, myvidx, m); for (int i = 0; i < m; i++) myvidx[i] = i; @@ -114,8 +114,6 @@ GetPerms (const Array &ar_in, bool uniq_v, bool do_sort = false) } while (std::next_permutation (myvidx, myvidx + m, std::greater ())); - delete[] myvidx; - return res; } @@ -131,7 +129,7 @@ GetPermsNoSort (const Array &ar_in, bool uniq_v = false) double nr = Factorial (m); // Setup index vector filled from 0..m-1 - int* myvidx = new int[m]; + OCTAVE_LOCAL_BUFFER (int, myvidx, m); for (int i = 0; i < m; i++) myvidx[i] = i; @@ -179,8 +177,6 @@ GetPermsNoSort (const Array &ar_in, bool uniq_v = false) } while (std::next_permutation (myvidx, myvidx + m, std::greater ())); - delete[] myvidx; - return res; }