octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #63803] Saving causes OOM, crash, and loss of


From: Rik
Subject: [Octave-bug-tracker] [bug #63803] Saving causes OOM, crash, and loss of already saved data
Date: Tue, 14 Feb 2023 20:11:19 -0500 (EST)

Follow-up Comment #13, bug #63803 (project octave):

One last question.  In ov-bool-mat.cc the code is now


  boolNDArray m = bool_array_value ();
  const bool *mtmp = m.data ();
  octave_idx_type nel = m.numel ();
  os.write (reinterpret_cast<const char*> (mtmp), nel);


But, octave_bool_matrix is


class
octave_bool_matrix : public octave_base_matrix<boolNDArray>


and the member variable "m_matrix" is already of type boolNDArray.  Thus, the
definition of bool_array_value() is


  boolNDArray bool_array_value (bool = false) const
  { return m_matrix; }


So, instead of creating the temporary boolNDArray value m, we could just
write


const bool *mtmp = m_matrix.data ();


I suppose the disadvantage would be if we changed the underlying data type of
octave_base_matrix then this approach might not work, while the original
would.  Of course, I don't think we would be changing data types all that
frequently and it would probably be a big deal for us to do so and we would
scrub the code base for these things anyways.

Alternatively, if we keep the existing structure, would it be better to use
either copy constructor or initialization rather than an assignment operator? 
It seems to me that assignment operator will first call boolNDArray
constructor with zero arguments, and then call assignment operator.  Maybe
optimizing compiler edits out the first empty construction, but if not that is
just wasted effort.

So, two additional proposals might be


  boolNDArray m (bool_array_value ());
  const bool *mtmp = m.data ();


or


  boolNDArray m {bool_array_value ()};
  const bool *mtmp = m.data ();


Thoughts?


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63803>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]