comparison liboctave/Array.h @ 13990:c9a0e5343cd8

use static storage for array nil rep instead of allocating it with new * Array.h (Array<T>::ArrayRep::nil_rep): Use static object for nil rep instead of allocating it with new.
author John W. Eaton <jwe@octave.org>
date Sun, 04 Dec 2011 03:38:45 -0500
parents 43cc49c7abd1
children 72c96de7a403
comparison
equal deleted inserted replaced
13989:b4d399c975de 13990:c9a0e5343cd8
154 154
155 private: 155 private:
156 156
157 typename Array<T>::ArrayRep *nil_rep (void) const 157 typename Array<T>::ArrayRep *nil_rep (void) const
158 { 158 {
159 static typename Array<T>::ArrayRep *nr 159 // NR was originally allocated with new, but that does not seem
160 = new typename Array<T>::ArrayRep (); 160 // to be necessary since it will never be deleted. So just use
161 161 // a static object instead.
162 return nr; 162
163 static typename Array<T>::ArrayRep nr;
164 return &nr;
163 } 165 }
164 166
165 public: 167 public:
166 168
167 // Empty ctor (0x0). 169 // Empty ctor (0x0).