From 8ea3ecaf3c4d554a2feb57ab551df73a701887d0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 25 Jul 2019 14:04:43 +0300 Subject: code cleaning --- src/mir_app/src/netlibhttp.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/mir_app/src/netlibhttp.cpp b/src/mir_app/src/netlibhttp.cpp index 575aff8623..4936841796 100644 --- a/src/mir_app/src/netlibhttp.cpp +++ b/src/mir_app/src/netlibhttp.cpp @@ -428,9 +428,6 @@ MIR_APP_DLL(int) Netlib_SendHttpRequest(HNETLIBCONN nlc, NETLIBHTTPREQUEST *nlhr if (!(nlhr->flags & NLHRF_MANUALHOST)) { bool usingProxy = nlc->proxyType == PROXYTYPE_HTTP && !(nlhr->flags & NLHRF_SSL); - mir_free(szHost); - szHost = nullptr; - const char *ppath, *phost; phost = strstr(pszUrl, "://"); if (phost == nullptr) phost = pszUrl; @@ -439,7 +436,7 @@ MIR_APP_DLL(int) Netlib_SendHttpRequest(HNETLIBCONN nlc, NETLIBHTTPREQUEST *nlhr if (ppath == phost) phost = nullptr; - szHost = mir_strdup(phost); + replaceStr(szHost, phost); if (ppath && phost) szHost[ppath - phost] = 0; @@ -453,12 +450,11 @@ MIR_APP_DLL(int) Netlib_SendHttpRequest(HNETLIBCONN nlc, NETLIBHTTPREQUEST *nlhr char *cln = strchr(tszHost, ':'); if (cln) *cln = 0; if (inet_addr(tszHost) == INADDR_NONE) { - DWORD ip = DnsLookup(nlu, tszHost); - if (ip && szHost) { + in_addr ip; + if (ip.S_un.S_addr = DnsLookup(nlu, tszHost)) { mir_free(szHost); - szHost = (char*)mir_alloc(64); if (cln) *cln = ':'; - mir_snprintf(szHost, 64, "%s%s", inet_ntoa(*(PIN_ADDR)&ip), cln ? cln : ""); + szHost = CMStringA(FORMAT, "%s%s", inet_ntoa(ip), cln ? cln : "").Detach(); } } mir_free(tszHost); -- cgit v1.2.3