On 07/18/2017 11:30 AM, John W. Eaton
wrote:
On
07/18/2017 01:41 PM, Rik wrote:
7/18/17
jwe,
In the goal of simplifying the code base and relying more on
standard
libraries rather than handspun code, would it make sense to
replace the
implementation of octave_local_buffer with std::unique_ptr
(http://www.cplusplus.com/reference/memory/unique_ptr/)? The
purpose of
unique_ptr is to provide an efficient garbage collection
mechanism for the
managed pointer such that when the unique_ptr object goes out of
scope,
either due to reaching the end of a function or because an
exception has
been triggered, any allocated memory is released.
Seems like it would be simple to keep the OCTAVE_LOCAL_BUFFER
macro for the
moment but just change the implementation to use unique_ptr.
--Rik
I'd be in favor of doing that. It's been discussed before and we
this open bug report:
https://savannah.gnu.org/bugs/?48793
It wasn't that hard so I made two different implementations of
OCTAVE_LOCAL_BUFFER. One based on bytes, and one based on the
passed in object type T. Unfortunately, while they compile just
fine, the resulting binary segfaults. I think what this really
means is that there are issues in Octave code around double frees
of memory. I've put my work up on the bug report you mentioned.
--Rik
|