Mercurial > octave
changeset 30430:e5ff1b174ddf
maint: Merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 04 Dec 2021 11:00:16 -0500 |
parents | d1d96e1339e3 (current diff) e38202d3628d (diff) |
children | b6fdc8574e7d |
files | libinterp/corefcn/mex.cc libinterp/corefcn/oct-stream.h |
diffstat | 14 files changed, 87 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/mex.cc Sat Dec 04 16:46:48 2021 +0100 +++ b/libinterp/corefcn/mex.cc Sat Dec 04 11:00:16 2021 -0500 @@ -255,10 +255,43 @@ // #define DEBUG 1 +#if DEBUG +# include <iostream> +#endif + +static void * +xmalloc (size_t n) +{ + void *ptr = std::malloc (n); + +#if DEBUG + std::cerr << "xmalloc (" << n << ") = " << ptr << std::endl; +#endif + + return ptr; +} + +static void * +xrealloc (void *ptr, size_t n) +{ + void *newptr = std::realloc (ptr, n); + +#if DEBUG + std::cerr << "xrealloc (" << ptr << ", " << n << ") = " << newptr + << std::endl; +#endif + + return newptr; +} + static void xfree (void *ptr) { - ::free (ptr); +#if DEBUG + std::cerr << "xfree (" << ptr << ")" << std::endl; +#endif + + std::free (ptr); } static mwSize @@ -3276,7 +3309,7 @@ // Allocate memory. void * malloc_unmarked (std::size_t n) { - void *ptr = std::malloc (n); + void *ptr = xmalloc (n); if (! ptr) { @@ -3332,7 +3365,7 @@ auto p_local = m_memlist.find (ptr); auto p_global = s_global_memlist.find (ptr); - v = std::realloc (ptr, n); + v = xrealloc (ptr, n); if (v) { @@ -3542,7 +3575,7 @@ void * mxArray::malloc (std::size_t n) { - return mex_context ? mex_context->malloc_unmarked (n) : std::malloc (n); + return mex_context ? mex_context->malloc_unmarked (n) : xmalloc (n); } void * @@ -3662,14 +3695,14 @@ void * mxMalloc (std::size_t n) { - return mex_context ? mex_context->malloc (n) : std::malloc (n); + return mex_context ? mex_context->malloc (n) : xmalloc (n); } void * mxRealloc (void *ptr, std::size_t size) { - return mex_context ? mex_context->realloc (ptr, size) - : std::realloc (ptr, size); + return (mex_context + ? mex_context->realloc (ptr, size) : xrealloc (ptr, size)); } void
--- a/libinterp/corefcn/oct-stream.h Sat Dec 04 16:46:48 2021 +0100 +++ b/libinterp/corefcn/oct-stream.h Sat Dec 04 11:00:16 2021 -0500 @@ -37,12 +37,12 @@ // These only appear as reference arguments or return values. -template <typename T> class Array; class Cell; class octave_value; class octave_value_list; class string_vector; +#include "Array-fwd.h" #include "data-conv.h" #include "mach-info.h"
--- a/libinterp/corefcn/pr-output.h Sat Dec 04 16:46:48 2021 +0100 +++ b/libinterp/corefcn/pr-output.h Sat Dec 04 11:00:16 2021 -0500 @@ -30,12 +30,12 @@ #include <iosfwd> +#include "Array-fwd.h" #include "oct-cmplx.h" #include "oct-inttypes-fwd.h" #include "pr-flt-fmt.h" -template <typename T> class Array; class ComplexMatrix; class FloatComplexMatrix; class ComplexDiagMatrix;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/liboctave/array/Array-fwd.h Sat Dec 04 11:00:16 2021 -0500 @@ -0,0 +1,33 @@ +//////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 The Octave Project Developers +// +// See the file COPYRIGHT.md in the top-level directory of this +// distribution or <https://octave.org/copyright/>. +// +// This file is part of Octave. +// +// Octave is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Octave is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Octave; see the file COPYING. If not, see +// <https://www.gnu.org/licenses/>. +// +//////////////////////////////////////////////////////////////////////// + +#if ! defined (octave_Array_fwd_h) +#define octave_Array_fwd_h 1 + +#include "octave-config.h" + +template <typename T> class OCTARRAY_API Array; + +#endif
--- a/liboctave/array/Array.h Sat Dec 04 16:46:48 2021 +0100 +++ b/liboctave/array/Array.h Sat Dec 04 11:00:16 2021 -0500 @@ -35,6 +35,7 @@ #include <iosfwd> #include <string> +#include "Array-fwd.h" #include "dim-vector.h" #include "idx-vector.h" #include "lo-error.h" @@ -122,9 +123,6 @@ //! - string_vector: Array<std::string> with 1 column //! - Cell: Array<octave_value>, equivalent to an Octave cell. -// forward declare template with visibility attribute -template <typename T> class OCTARRAY_API Array; - template <typename T> class Array
--- a/liboctave/array/Range.h Sat Dec 04 16:46:48 2021 +0100 +++ b/liboctave/array/Range.h Sat Dec 04 11:00:16 2021 -0500 @@ -30,13 +30,12 @@ #include <iosfwd> +#include "Array-fwd.h" #include "dMatrix.h" #include "dim-vector.h" #include "lo-error.h" #include "oct-sort.h" -template <typename T> class Array; - namespace octave { template <typename T>
--- a/liboctave/array/Sparse.h Sat Dec 04 16:46:48 2021 +0100 +++ b/liboctave/array/Sparse.h Sat Dec 04 11:00:16 2021 -0500 @@ -35,8 +35,9 @@ #include <iosfwd> #include <string> +#include "Array-fwd.h" + class PermMatrix; -template <typename T> class Array; // Two dimensional sparse class. Handles the reference counting for // all the derived classes.
--- a/liboctave/array/dim-vector.h Sat Dec 04 16:46:48 2021 +0100 +++ b/liboctave/array/dim-vector.h Sat Dec 04 11:00:16 2021 -0500 @@ -36,11 +36,10 @@ #include <initializer_list> #include <string> +#include "Array-fwd.h" #include "oct-atomic.h" #include "oct-refcount.h" -template <typename T> class Array; - //! Vector representing the dimensions (size) of an Array. //! //! A dim_vector is used to represent dimensions of an Array. It is used
--- a/liboctave/array/idx-vector.h Sat Dec 04 16:46:48 2021 +0100 +++ b/liboctave/array/idx-vector.h Sat Dec 04 11:00:16 2021 -0500 @@ -35,11 +35,11 @@ #include <iosfwd> #include <memory> +#include "Array-fwd.h" #include "dim-vector.h" #include "oct-inttypes-fwd.h" #include "oct-refcount.h" -template <typename T> class Array; template <typename T> class Sparse; namespace octave
--- a/liboctave/array/module.mk Sat Dec 04 16:46:48 2021 +0100 +++ b/liboctave/array/module.mk Sat Dec 04 11:00:16 2021 -0500 @@ -1,6 +1,7 @@ ARRAY_INC = \ + %reldir%/Array-fwd.h \ + %reldir%/Array-util.h \ %reldir%/Array.h \ - %reldir%/Array-util.h \ %reldir%/boolMatrix.h \ %reldir%/boolNDArray.h \ %reldir%/boolSparse.h \
--- a/liboctave/numeric/oct-spparms.h Sat Dec 04 16:46:48 2021 +0100 +++ b/liboctave/numeric/oct-spparms.h Sat Dec 04 11:00:16 2021 -0500 @@ -31,11 +31,10 @@ #include <iosfwd> #include <string> +#include "Array-fwd.h" #include "str-vec.h" #include "dColVector.h" -template <typename T> class Array; - #define OCTAVE_SPARSE_CONTROLS_SIZE 13 namespace octave
--- a/liboctave/numeric/qr.h Sat Dec 04 16:46:48 2021 +0100 +++ b/liboctave/numeric/qr.h Sat Dec 04 11:00:16 2021 -0500 @@ -28,7 +28,7 @@ #include "octave-config.h" -template <typename T> class Array; +#include "Array-fwd.h" namespace octave {
--- a/liboctave/util/oct-base64.h Sat Dec 04 16:46:48 2021 +0100 +++ b/liboctave/util/oct-base64.h Sat Dec 04 11:00:16 2021 -0500 @@ -30,10 +30,9 @@ #include <string> +#include "Array-fwd.h" #include "intNDArray.h" -template <typename T> class Array; - namespace octave { extern OCTAVE_API bool
--- a/liboctave/util/url-transfer.h Sat Dec 04 16:46:48 2021 +0100 +++ b/liboctave/util/url-transfer.h Sat Dec 04 11:00:16 2021 -0500 @@ -33,10 +33,9 @@ #include <ostream> #include <string> +#include "Array-fwd.h" #include "str-vec.h" -template <typename T> class Array; - namespace octave { struct weboptions