aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <unknown>2007-03-21 23:40:18 +0000
committernyamatongwe <unknown>2007-03-21 23:40:18 +0000
commit515090de5b6d5448ed0a3e2cf6afd03c9ff5ac90 (patch)
tree34cfa7dca663f853aed5bf08398938cd4ec8986c /src
parent20a5ec3bf14198772fa4e842900ab0ce0a54cba4 (diff)
downloadscintilla-mirror-515090de5b6d5448ed0a3e2cf6afd03c9ff5ac90.tar.gz
When deleting all contents of a SplitVector, free the memory.
Diffstat (limited to 'src')
-rw-r--r--src/SplitVector.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/SplitVector.h b/src/SplitVector.h
index e923915d8..4b9875b4a 100644
--- a/src/SplitVector.h
+++ b/src/SplitVector.h
@@ -49,9 +49,7 @@ protected:
}
}
-public:
- /// Construct a split buffer.
- SplitVector() {
+ void Init() {
body = NULL;
growSize = 8;
size = 0;
@@ -60,13 +58,17 @@ public:
gapLength = 0;
}
+public:
+ /// Construct a split buffer.
+ SplitVector() {
+ Init();
+ }
+
~SplitVector() {
delete []body;
body = NULL;
}
- void Create(int initialLength_, int growSize_);
-
int GetGrowSize() const {
return growSize;
}
@@ -212,7 +214,11 @@ public:
if ((position < 0) || ((position + deleteLength) > lengthBody)) {
return;
}
- if (deleteLength > 0) {
+ if ((position == 0) && (deleteLength == lengthBody)) {
+ // Full deallocation returns storage and is faster
+ delete []body;
+ Init();
+ } else if (deleteLength > 0) {
GapTo(position);
lengthBody -= deleteLength;
gapLength += deleteLength;