aboutsummaryrefslogtreecommitdiffstats
path: root/win/vncconfig/Connections.h
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2023-01-11 17:21:56 +0100
committerPierre Ossman <ossman@cendio.se>2023-02-04 14:03:13 +0100
commit19badc4def7d2bee677da3a02e1117f1e051a8cd (patch)
tree2dc20f1bcbda813d2616b32856994f558a4c1eab /win/vncconfig/Connections.h
parent337dbc392253af92b0577da062a5abc1d032b1ef (diff)
downloadtigervnc-19badc4def7d2bee677da3a02e1117f1e051a8cd.tar.gz
tigervnc-19badc4def7d2bee677da3a02e1117f1e051a8cd.zip
Make strSplit() simpler and safer
Get rid of all the magical re-allocation and shuffling and instead just return a new set of strings that is fully splitted. Will consume a bit more memory, but is a lot safer to use as there is less confusion about ownership of memory.
Diffstat (limited to 'win/vncconfig/Connections.h')
-rw-r--r--win/vncconfig/Connections.h12
1 files changed, 5 insertions, 7 deletions
diff --git a/win/vncconfig/Connections.h b/win/vncconfig/Connections.h
index f9b66547..492525f3 100644
--- a/win/vncconfig/Connections.h
+++ b/win/vncconfig/Connections.h
@@ -100,13 +100,11 @@ namespace rfb {
while (SendMessage(listBox, LB_GETCOUNT, 0, 0))
SendMessage(listBox, LB_DELETESTRING, 0, 0);
- CharArray tmp;
- tmp.buf = strDup(hosts.getValueStr().c_str());
- while (tmp.buf) {
- CharArray first;
- strSplit(tmp.buf, ',', &first.buf, &tmp.buf);
- if (strlen(first.buf))
- SendMessage(listBox, LB_ADDSTRING, 0, (LPARAM)first.buf);
+ std::vector<std::string> hostv;
+ hostv = strSplit(hosts, ',');
+ for (size_t i = 0; i < hostv.size(); i++) {
+ if (!hostv[i].empty())
+ SendMessage(listBox, LB_ADDSTRING, 0, (LPARAM)hostv[i].c_str());
}
onCommand(IDC_RFB_ENABLE, EN_CHANGE);