changeset 32137:644ad8448c49

new function to call object destructor if only one reference remains * ov.h (octave_value::maybe_call_dtor): New function. * ov-base.h (octave_base_value::maybe_call_dtor): New virtual function. * ov-cleanup.h (octave_oncleanup::maybe_call_dtor): New function.
author Petter T. <petter.vilhelm@gmail.com>
date Mon, 19 Jun 2023 10:45:49 -0400
parents bd26d9693501
children 45d89e3bebfd
files libinterp/octave-value/ov-base.h libinterp/octave-value/ov-oncleanup.h libinterp/octave-value/ov.h
diffstat 3 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/octave-value/ov-base.h	Mon Jun 19 10:27:30 2023 -0400
+++ b/libinterp/octave-value/ov-base.h	Mon Jun 19 10:45:49 2023 -0400
@@ -792,6 +792,8 @@
 
   virtual void call_object_destructor () { }
 
+  virtual void maybe_call_dtor () { }
+
   virtual octave_value dump () const;
 
   virtual octave_value storable_value (void);
--- a/libinterp/octave-value/ov-oncleanup.h	Mon Jun 19 10:27:30 2023 -0400
+++ b/libinterp/octave-value/ov-oncleanup.h	Mon Jun 19 10:45:49 2023 -0400
@@ -91,6 +91,12 @@
 
   void call_object_destructor ();
 
+  void maybe_call_dtor () 
+  { 
+    if (m_count == 1)
+      call_object_destructor ();  
+  }
+
 private:
 
   DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
--- a/libinterp/octave-value/ov.h	Mon Jun 19 10:27:30 2023 -0400
+++ b/libinterp/octave-value/ov.h	Mon Jun 19 10:45:49 2023 -0400
@@ -1555,6 +1555,8 @@
     return m_rep->fcn_cache_value ();
   }
 
+  void maybe_call_dtor () { m_rep->maybe_call_dtor (); }
+
   octave_value
   checked_full_matrix_elem (octave_idx_type n) const
   { return m_rep->checked_full_matrix_elem (n); }