From 91c4a9ff07821dce93dab3ffd77df081893b723d Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 10 May 2017 13:58:06 +1000 Subject: Use unique_ptr fpr Partitioning, RunStyles, SparseVector, PositionCache and Document. --- src/SparseVector.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/SparseVector.h') diff --git a/src/SparseVector.h b/src/SparseVector.h index 250ce97ac..39324bdc1 100644 --- a/src/SparseVector.h +++ b/src/SparseVector.h @@ -17,8 +17,8 @@ namespace Scintilla { template class SparseVector { private: - Partitioning *starts; - SplitVector *values; + std::unique_ptr starts; + std::unique_ptr> values; // Deleted so SparseVector objects can not be copied. SparseVector(const SparseVector &) = delete; void operator=(const SparseVector &) = delete; @@ -55,19 +55,17 @@ private: } public: SparseVector() { - starts = new Partitioning(8); - values = new SplitVector(); + starts.reset(new Partitioning(8)); + values.reset(new SplitVector()); values->InsertValue(0, 2, T()); } ~SparseVector() { - delete starts; - starts = NULL; + starts.reset(); // starts dead here but not used by ClearValue. for (int part = 0; part < values->Length(); part++) { ClearValue(part); } - delete values; - values = NULL; + values.reset(); } int Length() const { return starts->PositionFromPartition(starts->Partitions()); -- cgit v1.2.3