diff options
author | Pierre Ossman <ossman@cendio.se> | 2023-01-17 16:49:01 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2023-02-04 14:03:13 +0100 |
commit | 7f20bff3561dd942a39ce3ecf604c7c9673bad37 (patch) | |
tree | 3cae1d8cbd0938a595740882c6c2c95572dc5477 | |
parent | 741300728a889b4ccaec35bd57efb072018c860c (diff) | |
download | tigervnc-7f20bff3561dd942a39ce3ecf604c7c9673bad37.tar.gz tigervnc-7f20bff3561dd942a39ce3ecf604c7c9673bad37.zip |
Remove unneeded CharArray:s
Avoid complicating things by moving things in to a second buffer here as
there is no need for it.
-rw-r--r-- | common/network/TcpSocket.cxx | 21 | ||||
-rw-r--r-- | win/rfb_win32/Dialog.cxx | 9 | ||||
-rw-r--r-- | win/rfb_win32/RegConfig.cxx | 10 |
3 files changed, 18 insertions, 22 deletions
diff --git a/common/network/TcpSocket.cxx b/common/network/TcpSocket.cxx index 8424a4d6..cc82faef 100644 --- a/common/network/TcpSocket.cxx +++ b/common/network/TcpSocket.cxx @@ -711,21 +711,18 @@ TcpFilter::Pattern TcpFilter::parsePattern(const char* p) { } char* TcpFilter::patternToStr(const TcpFilter::Pattern& p) { - rfb::CharArray addr; - char buffer[INET6_ADDRSTRLEN + 2]; + char addr[INET6_ADDRSTRLEN + 2]; if (p.address.u.sa.sa_family == AF_INET) { getnameinfo(&p.address.u.sa, sizeof(p.address.u.sin), - buffer, sizeof (buffer), NULL, 0, NI_NUMERICHOST); - addr.buf = rfb::strDup(buffer); + addr, sizeof(addr), NULL, 0, NI_NUMERICHOST); } else if (p.address.u.sa.sa_family == AF_INET6) { - buffer[0] = '['; + addr[0] = '['; getnameinfo(&p.address.u.sa, sizeof(p.address.u.sin6), - buffer + 1, sizeof (buffer) - 2, NULL, 0, NI_NUMERICHOST); - strcat(buffer, "]"); - addr.buf = rfb::strDup(buffer); + addr + 1, sizeof(addr) - 2, NULL, 0, NI_NUMERICHOST); + strcat(addr, "]"); } else - addr.buf = rfb::strDup(""); + addr[0] = '\0'; char action; switch (p.action) { @@ -735,15 +732,15 @@ char* TcpFilter::patternToStr(const TcpFilter::Pattern& p) { case Query: action = '?'; break; }; size_t resultlen = (1 // action - + strlen (addr.buf) // address + + strlen (addr) // address + 1 // slash + 3 // prefix length, max 128 + 1); // terminating nul char* result = new char[resultlen]; - if (addr.buf[0] == '\0') + if (addr[0] == '\0') snprintf(result, resultlen, "%c", action); else - snprintf(result, resultlen, "%c%s/%u", action, addr.buf, p.prefixlen); + snprintf(result, resultlen, "%c%s/%u", action, addr, p.prefixlen); return result; } diff --git a/win/rfb_win32/Dialog.cxx b/win/rfb_win32/Dialog.cxx index cb480506..ecba9747 100644 --- a/win/rfb_win32/Dialog.cxx +++ b/win/rfb_win32/Dialog.cxx @@ -300,13 +300,12 @@ bool PropSheet::showPropSheet(HWND owner, bool showApply, bool showCtxtHelp, boo char title[128]; if (!GetWindowText(PropSheet_GetCurrentPageHwnd(handle), title, sizeof(title))) sprintf(title, "capture%d", i); - CharArray pageTitle(strDup(title)); - for (int j=0; j<strlen(pageTitle.buf); j++) { - if (pageTitle.buf[j] == '/' || pageTitle.buf[j] == '\\' || pageTitle.buf[j] == ':') - pageTitle.buf[j] = '-'; + for (int j=0; j<strlen(title); j++) { + if (title == '/' || title[j] == '\\' || title[j] == ':') + title[j] = '-'; } char filename[256]; - sprintf(filename, "%s\\%s.bmp", tmpdir, pageTitle.buf); + sprintf(filename, "%s\\%s.bmp", tmpdir, title); vlog.debug("writing to %s", filename); saveBMP(filename, &fb); i++; diff --git a/win/rfb_win32/RegConfig.cxx b/win/rfb_win32/RegConfig.cxx index 3d5af9e3..73a9e699 100644 --- a/win/rfb_win32/RegConfig.cxx +++ b/win/rfb_win32/RegConfig.cxx @@ -61,11 +61,11 @@ void RegConfig::loadRegistryConfig(RegKey& key) { DWORD i = 0; try { while (1) { - CharArray name(strDup(key.getValueName(i++))); - if (!name.buf) break; - CharArray value(key.getRepresentation(name.buf)); - if (!value.buf || !Configuration::setParam(name.buf, value.buf)) - vlog.info("unable to process %s", name.buf); + const char *name = key.getValueName(i++); + if (!name) break; + CharArray value(key.getRepresentation(name)); + if (!value.buf || !Configuration::setParam(name, value.buf)) + vlog.info("unable to process %s", name); } } catch (rdr::SystemException& e) { if (e.err != 6) |