rbutilqt: Simplify conversion from UTF-16 string to QString for proxy host
rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Mon, 29 Jun 2026 17:41:30 -0400
| Newsgroups | gmane.comp.systems.archos.rockbox.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 05de3651d21649eb2985c1fc6b1b86eef5d731f6 Author: Vencislav Atanasov <[email protected]> Date: Mon Jun 29 22:07:42 2026 +0300 rbutilqt: Simplify conversion from UTF-16 string to QString for proxy host Co-authored-by: ChatGPT (GPT-5.3 Mini) <[email protected]> Change-Id: Idf3437f66c6ac95d38cad997143b995b2fe9a5f2 diff --git a/utils/rbutilqt/base/system.cpp b/utils/rbutilqt/base/system.cpp index 33de19f5d2..0ab0d9823a 100644 --- a/utils/rbutilqt/base/system.cpp +++ b/utils/rbutilqt/base/system.cpp @@ -461,8 +461,6 @@ QUrl System::systemProxy(void) CFNumberRef numberref; int enable = 0; int port = 0; - unsigned int bufsize = 0; - char *buf; QUrl proxy; dictref = SCDynamicStoreCopyProxies(NULL); @@ -475,24 +473,14 @@ QUrl System::systemProxy(void) // get proxy string stringref = (CFStringRef)CFDictionaryGetValue(dictref, kSCPropNetProxiesHTTPProxy); if(stringref != NULL) { - // get number of characters. CFStringGetLength uses UTF-16 code pairs - bufsize = CFStringGetLength(stringref) * 2 + 1; - buf = (char*)malloc(sizeof(char) * bufsize); - if(buf == NULL) { - LOG_ERROR() << "can't allocate memory for proxy string!"; - CFRelease(dictref); - return QUrl(""); - } - CFStringGetCString(stringref, buf, bufsize, kCFStringEncodingUTF16); + QString host = QString::fromCFString(stringref); numberref = (CFNumberRef)CFDictionaryGetValue(dictref, kSCPropNetProxiesHTTPPort); if(numberref != NULL) CFNumberGetValue(numberref, kCFNumberIntType, &port); proxy.setScheme("http"); - proxy.setHost(QString::fromUtf16((unsigned short*)buf)); + proxy.setHost(host); proxy.setPort(port); - - free(buf); - } + } } CFRelease(dictref); -- rockbox-cvs mailing list [email protected] https://lists.haxx.se/mailman/listinfo/rockbox-cvs