diff libinterp/dldfcn/colamd.cc @ 23777:cda0614beaec

Replace static instances of OCTAVE_LOCAL_BUFFER with local variables. * load-save.cc (check_gzip_magic): Replace OCTAVE_LOCAL_BUFFER magic with "unsigned char magic[2]". * regexp.cc (octregexp): Replace OCTAVE_LOCAL_BUFFER_INIT arg_used with "int arg_used[7] {}". Aggregate initialization zero initializes ints. * ccolamd.cc (Fccolamd, Fcsymand): Replace OCTAVE_LOCAL_BUFFER instances for knobs and stats with 1) a local variable XXX_storage, and 2) a pointer to the first element in XXX_storage. Also use static_assert to guarantee at compile time that the size of the local variable storage is not too large. * colamd.cc (Fcolamd, Fsymand): Replace OCTAVE_LOCAL_BUFFER instances for knobs and stats with 1) a local variable XXX_storage, and 2) a pointer to the first element in XXX_storage. Also use static_assert to guarantee at compile time that the size of the local variable storage is not too large. * Array.cc (hermitian): Remove comment about OCTAVE_LOCAL_BUFFER not being appropriate.
author Rik <rik@octave.org>
date Thu, 20 Jul 2017 21:25:06 -0700
parents b7747a2c88b2
children 980f39c3ab90
line wrap: on
line diff
--- a/libinterp/dldfcn/colamd.cc	Thu Jul 20 15:29:38 2017 -0700
+++ b/libinterp/dldfcn/colamd.cc	Thu Jul 20 21:25:06 2017 -0700
@@ -280,7 +280,9 @@
   int spumoni = 0;
 
   // Get knobs
-  OCTAVE_LOCAL_BUFFER (double, knobs, COLAMD_KNOBS);
+  static_assert (COLAMD_KNOBS <= 40, "colamd: # of COLAMD_KNOBS exceeded.  Please report this to bugs.octave.org");
+  double knob_storage[COLAMD_KNOBS];
+  double *knobs = &knob_storage[0];
   COLAMD_NAME (_set_defaults) (knobs);
 
   // Check for user-passed knobs
@@ -380,7 +382,9 @@
     A[i] = ridx[i];
 
   // Order the columns (destroys A)
-  OCTAVE_LOCAL_BUFFER (octave::suitesparse_integer, stats, COLAMD_STATS);
+  static_assert (COLAMD_STATS <= 40, "colamd: # of COLAMD_STATS exceeded.  Please report this to bugs.octave.org");
+  octave::suitesparse_integer stats_storage[COLAMD_STATS];
+  octave::suitesparse_integer *stats = &stats_storage[0];
   if (! COLAMD_NAME () (n_row, n_col, Alen, A, p, knobs, stats))
     {
       COLAMD_NAME (_report)(stats);
@@ -518,7 +522,9 @@
   int spumoni = 0;
 
   // Get knobs
-  OCTAVE_LOCAL_BUFFER (double, knobs, COLAMD_KNOBS);
+  static_assert (COLAMD_KNOBS <= 40, "symamd: # of COLAMD_KNOBS exceeded.  Please report this to bugs.octave.org");
+  double knob_storage[COLAMD_KNOBS];
+  double *knobs = &knob_storage[0];
   COLAMD_NAME (_set_defaults) (knobs);
 
   // Check for user-passed knobs
@@ -580,7 +586,9 @@
 
   // Allocate workspace for symamd
   OCTAVE_LOCAL_BUFFER (octave_idx_type, perm, n_col+1);
-  OCTAVE_LOCAL_BUFFER (octave::suitesparse_integer, stats, COLAMD_STATS);
+  static_assert (COLAMD_STATS <= 40, "symamd: # of COLAMD_STATS exceeded.  Please report this to bugs.octave.org");
+  octave::suitesparse_integer stats_storage[COLAMD_STATS];
+  octave::suitesparse_integer *stats = &stats_storage[0];
   if (! SYMAMD_NAME () (n_col, octave::to_suitesparse_intptr (ridx),
                         octave::to_suitesparse_intptr (cidx),
                         octave::to_suitesparse_intptr (perm),