aboutsummaryrefslogtreecommitdiffhomepage
path: root/qt/ScintillaEditBase/PlatQt.cpp
diff options
context:
space:
mode:
authornyamatongwe <unknown>2013-05-04 23:38:19 +1000
committernyamatongwe <unknown>2013-05-04 23:38:19 +1000
commitc37c824e3a9f0ef57c5cdd41a42834b55ed78b91 (patch)
treeb709170bd7a00a7d56ace176bf2743f8ec99085f /qt/ScintillaEditBase/PlatQt.cpp
parenta06f5a50adf59e79f95b73d5db5a9f8e758f8af7 (diff)
downloadscintilla-mirror-c37c824e3a9f0ef57c5cdd41a42834b55ed78b91.tar.gz
Replacing raw pointers and allocations with std::vector and std::string.
Diffstat (limited to 'qt/ScintillaEditBase/PlatQt.cpp')
-rw-r--r--qt/ScintillaEditBase/PlatQt.cpp36
1 files changed, 16 insertions, 20 deletions
diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp
index c7ec303ed..83512ba0b 100644
--- a/qt/ScintillaEditBase/PlatQt.cpp
+++ b/qt/ScintillaEditBase/PlatQt.cpp
@@ -979,30 +979,26 @@ void ListBoxImpl::SetList(const char *list, char separator, char typesep)
// It is borrowed from the GTK implementation.
Clear();
int count = strlen(list) + 1;
- char *words = new char[count];
- if (words) {
- memcpy(words, list, count);
- char *startword = words;
- char *numword = NULL;
- int i = 0;
- for (; words[i]; i++) {
- if (words[i] == separator) {
- words[i] = '\0';
- if (numword)
- *numword = '\0';
- Append(startword, numword?atoi(numword + 1):-1);
- startword = words + i + 1;
- numword = NULL;
- } else if (words[i] == typesep) {
- numword = words + i;
- }
- }
- if (startword) {
+ std::vector<char> words(list, list+count);
+ char *startword = words.data();
+ char *numword = NULL;
+ int i = 0;
+ for (; words[i]; i++) {
+ if (words[i] == separator) {
+ words[i] = '\0';
if (numword)
*numword = '\0';
Append(startword, numword?atoi(numword + 1):-1);
+ startword = words.data() + i + 1;
+ numword = NULL;
+ } else if (words[i] == typesep) {
+ numword = words.data() + i;
}
- delete []words;
+ }
+ if (startword) {
+ if (numword)
+ *numword = '\0';
+ Append(startword, numword?atoi(numword + 1):-1);
}
}