aboutsummaryrefslogtreecommitdiffstats
path: root/win/rfb_win32/Registry.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2023-01-15 16:55:34 +0100
committerPierre Ossman <ossman@cendio.se>2023-02-04 14:03:13 +0100
commit2047dae22fb862ff43309ebb4fe2b9e7d6ce6153 (patch)
tree975687d97e31e677f827e0f586a349868e6a1e65 /win/rfb_win32/Registry.cxx
parentea6afa9b791e3782455a829f97515fa721edd522 (diff)
downloadtigervnc-2047dae22fb862ff43309ebb4fe2b9e7d6ce6153.tar.gz
tigervnc-2047dae22fb862ff43309ebb4fe2b9e7d6ce6153.zip
Return std::vector instead of dynamic allocation
This makes memory management more clear and robust when using these helper functions.
Diffstat (limited to 'win/rfb_win32/Registry.cxx')
-rw-r--r--win/rfb_win32/Registry.cxx20
1 files changed, 7 insertions, 13 deletions
diff --git a/win/rfb_win32/Registry.cxx b/win/rfb_win32/Registry.cxx
index cb4e6688..78879c3b 100644
--- a/win/rfb_win32/Registry.cxx
+++ b/win/rfb_win32/Registry.cxx
@@ -173,23 +173,17 @@ TCHAR* RegKey::getString(const TCHAR* valname, const TCHAR* def) const {
}
}
-void RegKey::getBinary(const TCHAR* valname, void** data, size_t* length) const {
+std::vector<uint8_t> RegKey::getBinary(const TCHAR* valname) const {
TCharArray hex(getRepresentation(valname));
- *data = hexToBin(CStr(hex.buf), strlen(CStr(hex.buf)));
- *length = strlen(CStr(hex.buf))/2;
- if (*data == NULL)
- throw rdr::Exception("getBinary failed");
+ return hexToBin(CStr(hex.buf), strlen(CStr(hex.buf)));
}
-void RegKey::getBinary(const TCHAR* valname, void** data, size_t* length, void* def, size_t deflen) const {
+std::vector<uint8_t> RegKey::getBinary(const TCHAR* valname, const uint8_t* def, size_t deflen) const {
try {
- getBinary(valname, data, length);
+ return getBinary(valname);
} catch(rdr::Exception&) {
- if (deflen) {
- *data = new char[deflen];
- memcpy(*data, def, deflen);
- } else
- *data = 0;
- *length = deflen;
+ std::vector<uint8_t> out(deflen);
+ memcpy(out.data(), def, deflen);
+ return out;
}
}