# HG changeset patch # User John W. Eaton # Date 1323063054 18000 # Node ID 8a566473361e297bc0933b9570483a4958fc2591 # Parent 99f039289e95a40ca125f534eae739e1cb8f4413 use static storage for Sparse nil rep instead of allocating it with new * Sparse.h (Sparse::SparseRep::nil_rep): Use static object for nil rep instead of allocating it with new. (Sparse::Sparse (void)): Increment count here, not in Sparse::SparseRep::nil_rep. diff -r 99f039289e95 -r 8a566473361e liboctave/Sparse.h --- a/liboctave/Sparse.h Mon Dec 05 00:30:51 2011 -0500 +++ b/liboctave/Sparse.h Mon Dec 05 00:30:54 2011 -0500 @@ -169,18 +169,17 @@ typename Sparse::SparseRep *nil_rep (void) const { - static typename Sparse::SparseRep *nr - = new typename Sparse::SparseRep (); - - nr->count++; - - return nr; + static typename Sparse::SparseRep nr; + return &nr; } public: Sparse (void) - : rep (nil_rep ()), dimensions (dim_vector(0,0)) { } + : rep (nil_rep ()), dimensions (dim_vector(0,0)) + { + rep->count++; + } explicit Sparse (octave_idx_type n) : rep (new typename Sparse::SparseRep (n)),