aboutsummaryrefslogtreecommitdiffhomepage
path: root/qt/ScintillaEditBase/PlatQt.cpp
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2013-05-04 23:38:19 +1000
committernyamatongwe <devnull@localhost>2013-05-04 23:38:19 +1000
commitdc758e3aac956c0d444ab5f65b16a3e35a437ce3 (patch)
treeea5befd4c5226b4e3d3aa0cbc4c6a35a2081d51a /qt/ScintillaEditBase/PlatQt.cpp
parent7ae647b68b12752ab3798e63fc67ac27331420c0 (diff)
downloadscintilla-mirror-dc758e3aac956c0d444ab5f65b16a3e35a437ce3.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);
}
}