Mercurial > hg > octave-lyh
changeset 11506:964b7fd379f1
more constructor/destructor fixes
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 13 Jan 2011 05:42:24 -0500 |
parents | 9a308e96194e |
children | c3ad80f4ce36 |
files | liboctave/ChangeLog liboctave/file-stat.h liboctave/oct-locbuf.h |
diffstat | 3 files changed, 48 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,13 @@ +2011-01-13 John W. Eaton <jwe@octave.org> + + * oct-locbuf.h (octave_chunk_buffer::~octave_chunk_buffer): + Now virtual. + (class octave_local_buffer, class octave_chunk_buffer): + Don't allow copying or assignment. + + * file-stat.h (base_file_stat::~base_file_stat): + Now protected and virtual. + 2011-01-13 John W. Eaton <jwe@octave.org> * base-lu.h (base_lu::base_lu): Initialize all data members in
--- a/liboctave/file-stat.h +++ b/liboctave/file-stat.h @@ -75,8 +75,6 @@ return *this; } - ~base_file_stat (void) { } - // The minimum difference in file time stamp values. // FIXME -- this value should come from the filesystem itself. How // can we get that info? @@ -147,6 +145,8 @@ protected: + virtual ~base_file_stat (void) { } + // TRUE means we have already called stat. bool initialized;
--- a/liboctave/oct-locbuf.h +++ b/liboctave/oct-locbuf.h @@ -41,8 +41,13 @@ } ~octave_local_buffer (void) { delete [] data; } operator T *() const { return data; } + private: T *data; + + // No copying! + octave_local_buffer (const octave_local_buffer&); + octave_local_buffer& operator = (const octave_local_buffer&); }; // For buffers of POD types, we'll be more smart. There is one thing that @@ -59,6 +64,15 @@ class octave_chunk_buffer { +public: + + OCTAVE_API octave_chunk_buffer (size_t size); + + OCTAVE_API virtual ~octave_chunk_buffer (void); + + char *data (void) const { return dat; } + +private: static const size_t chunk_size; static char *top, *chunk; @@ -67,13 +81,9 @@ char *cnk; char *dat; -public: - - OCTAVE_API octave_chunk_buffer (size_t size); - - OCTAVE_API ~octave_chunk_buffer (void); - - char *data (void) const { return dat; } + // No copying! + octave_chunk_buffer (const octave_chunk_buffer&); + octave_chunk_buffer& operator = (const octave_chunk_buffer&); }; // This specializes octave_local_buffer to use the chunked buffer mechanism @@ -83,8 +93,13 @@ class octave_local_buffer<TYPE> : private octave_chunk_buffer \ { \ public: \ - octave_local_buffer (size_t size) : octave_chunk_buffer (size * sizeof (TYPE)) { } \ - operator TYPE *() const { return reinterpret_cast<TYPE *> (this->data ()); } \ + octave_local_buffer (size_t size) \ + : octave_chunk_buffer (size * sizeof (TYPE)) { } \ + \ + operator TYPE *() const \ + { \ + return reinterpret_cast<TYPE *> (this->data ()); \ + } \ } SPECIALIZE_POD_BUFFER (bool); @@ -107,7 +122,10 @@ class octave_local_buffer<T *> : private octave_chunk_buffer { public: - octave_local_buffer (size_t size) : octave_chunk_buffer (size * sizeof (T *)) { } + octave_local_buffer (size_t size) + : octave_chunk_buffer (size * sizeof (T *)) + { } + operator T **() const { return reinterpret_cast<T **> (this->data ()); } }; @@ -115,8 +133,14 @@ class octave_local_buffer<const T *> : private octave_chunk_buffer { public: - octave_local_buffer (size_t size) : octave_chunk_buffer (size * sizeof (const T *)) { } - operator const T **() const { return reinterpret_cast<const T **> (this->data ()); } + octave_local_buffer (size_t size) + : octave_chunk_buffer (size * sizeof (const T *)) + { } + + operator const T **() const + { + return reinterpret_cast<const T **> (this->data ()); + } }; // If the compiler supports dynamic stack arrays, we can use the attached hack