# HG changeset patch # User Jaroslav Hajek # Date 1233739102 -3600 # Node ID f274fbc297476291cfbef882f7b9ce6dc105c8f9 # Parent 9792c26bffc77c76beb6d568d5de2ea45d00cdca chunked buffer allocation for pointers diff -r 9792c26bffc7 -r f274fbc29747 liboctave/ChangeLog --- a/liboctave/ChangeLog Wed Feb 04 10:18:20 2009 +0100 +++ b/liboctave/ChangeLog Wed Feb 04 10:18:22 2009 +0100 @@ -1,3 +1,8 @@ +2009-02-04 Jaroslav Hajek + + * oct-locbuf.h: Specialize OCTAVE_LOCAL_BUFFER to use chunked + allocation for pointers and const pointers. + 2009-02-03 Benjamin Lindner * Makefile.in: Add missing library reference. diff -r 9792c26bffc7 -r f274fbc29747 liboctave/oct-locbuf.h --- a/liboctave/oct-locbuf.h Wed Feb 04 10:18:20 2009 +0100 +++ b/liboctave/oct-locbuf.h Wed Feb 04 10:18:22 2009 +0100 @@ -102,6 +102,23 @@ SPECIALIZE_POD_BUFFER (FloatComplex); // MORE ? +// All pointers and const pointers are also POD types. +template +class octave_local_buffer : private octave_chunk_buffer +{ +public: + octave_local_buffer (size_t size) : octave_chunk_buffer (size * sizeof (T *)) { } + operator T **() const { return reinterpret_cast (this->data ()); } +}; + +template +class octave_local_buffer : 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 (this->data ()); } +}; + // If the compiler supports dynamic stack arrays, we can use the attached hack // to place small buffer arrays on the stack. It may be even faster than our // obstack-like optimization, but is dangerous because stack is a very limited