diff options
author | George Hazan <ghazan@miranda.im> | 2022-10-06 14:33:30 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-10-06 14:33:30 +0300 |
commit | 43134f01d3bcf7d5abe6c84c297faf1372e38bda (patch) | |
tree | 4f5b5027abe753d01f976d716e7c8d34c3901800 /src | |
parent | 9a0350523aa1d59fcbe1adb44fffa2a7581165d4 (diff) |
uint8_t is far more kosher than char considering binary buffers
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/netlib_http.cpp | 13 | ||||
-rw-r--r-- | src/mir_core/src/binbuffer.cpp | 10 | ||||
-rw-r--r-- | src/mir_core/src/mir_core.def | 2 | ||||
-rw-r--r-- | src/mir_core/src/mir_core64.def | 2 |
4 files changed, 14 insertions, 13 deletions
diff --git a/src/mir_app/src/netlib_http.cpp b/src/mir_app/src/netlib_http.cpp index a93caf7116..7c94db57ca 100644 --- a/src/mir_app/src/netlib_http.cpp +++ b/src/mir_app/src/netlib_http.cpp @@ -777,7 +777,7 @@ MIR_APP_DLL(NETLIBHTTPREQUEST*) Netlib_RecvHttpHeaders(HNETLIBCONN hConnection, nlhr->headers = (NETLIBHTTPHEADER*)mir_calloc(sizeof(NETLIBHTTPHEADER) * headersCount); headersCount = 0; - for (char *pbuffer = buf.data();; headersCount++) { + for (char *pbuffer = (char*)buf.data();; headersCount++) { char *peol = strchr(pbuffer, '\n'); if (peol == nullptr || peol == pbuffer || (peol == (pbuffer+1) && *pbuffer == '\r')) break; @@ -970,22 +970,23 @@ static int NetlibHttpRecvChunkHeader(NetlibConnection *nlc, bool first, uint32_t buf.append(data, recvResult); // add chunk - const char *peol1 = (const char*)memchr(buf.data(), '\n', buf.length()); + auto *peol1 = (const char*)memchr(buf.data(), '\n', buf.length()); if (peol1 == nullptr) continue; - int cbRest = int(peol1 - buf.data()) + 1; + auto *pStart = (const char *)buf.data(); + int cbRest = int(peol1 - pStart) + 1; const char *peol2 = first ? peol1 : (const char*)memchr(peol1 + 1, '\n', buf.length() - cbRest); if (peol2 == nullptr) continue; - int sz = peol2 - buf.data() + 1; - int r = strtol(first ? buf.data() : peol1 + 1, nullptr, 16); + int sz = peol2 - pStart + 1; + int r = strtol(first ? pStart : peol1 + 1, nullptr, 16); if (r == 0) { const char *peol3 = strchr(peol2 + 1, '\n'); if (peol3 == nullptr) continue; - sz = peol3 - buf.data() + 1; + sz = peol3 - pStart + 1; } buf.remove(sz); // remove all our data from buffer nlc->foreBuf.appendBefore(buf.data(), buf.length()); diff --git a/src/mir_core/src/binbuffer.cpp b/src/mir_core/src/binbuffer.cpp index 3b961b489b..fbde7bfb4d 100644 --- a/src/mir_core/src/binbuffer.cpp +++ b/src/mir_core/src/binbuffer.cpp @@ -62,7 +62,7 @@ struct BufImpl } }; -__forceinline BufImpl* ptr2buf(char *p) +__forceinline BufImpl* ptr2buf(uint8_t *p) { return (p == nullptr) ? nullptr : (BufImpl*)p-1; } @@ -86,7 +86,7 @@ MBinBuffer::MBinBuffer(size_t preAlloc) BufImpl *p = (BufImpl *)mir_alloc(sizeof(BufImpl) + preAlloc); p->lockCount = 1; p->size = (unsigned)preAlloc; - m_buf = (char*)(p + 1); + m_buf = (uint8_t *)(p + 1); } MBinBuffer& MBinBuffer::operator=(MBinBuffer &&from) noexcept @@ -108,7 +108,7 @@ void MBinBuffer::append(const void *pBuf, size_t bufLen) BufImpl *p = ptr2buf(m_buf)->realloc(bufLen); if (p) { - m_buf = (char*)(p + 1); + m_buf = (uint8_t *)(p + 1); memcpy(m_buf + p->size, pBuf, bufLen); p->size += (unsigned)bufLen; } @@ -122,7 +122,7 @@ void MBinBuffer::appendBefore(const void *pBuf, size_t bufLen) BufImpl *p = ptr2buf(m_buf)->realloc(bufLen); if (p) { - m_buf = (char *)(p + 1); + m_buf = (uint8_t *)(p + 1); memmove(m_buf + bufLen, m_buf, p->size); memcpy(m_buf, pBuf, bufLen); p->size += (unsigned)bufLen; @@ -138,7 +138,7 @@ void MBinBuffer::assign(const void *pBuf, size_t bufLen) BufImpl *p = ptr2buf(m_buf)->alloc(bufLen); if (p) { p->size = (unsigned)bufLen; - m_buf = (char *)(p + 1); + m_buf = (uint8_t *)(p + 1); memcpy(m_buf, pBuf, bufLen); } else m_buf = nullptr; diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 140837fef9..0b62e5dcda 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -994,7 +994,7 @@ CallFunctionSync @1170 ??4MBinBuffer@@QAEAAV0@$$QAV0@@Z @1208 NONAME
?append@MBinBuffer@@QAEXPBXI@Z @1209 NONAME
?appendBefore@MBinBuffer@@QAEXPBXI@Z @1210 NONAME
-?data@MBinBuffer@@QBEPADXZ @1211 NONAME
+?data@MBinBuffer@@QBEPAEXZ @1211 NONAME
?isEmpty@MBinBuffer@@QBE_NXZ @1212 NONAME
?length@MBinBuffer@@QBEIXZ @1213 NONAME
?remove@MBinBuffer@@QAEXI@Z @1214 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index bf5cb32785..e7da28b523 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -994,7 +994,7 @@ CallFunctionSync @1170 ??4MBinBuffer@@QEAAAEAV0@$$QEAV0@@Z @1208 NONAME
?append@MBinBuffer@@QEAAXPEBX_K@Z @1209 NONAME
?appendBefore@MBinBuffer@@QEAAXPEBX_K@Z @1210 NONAME
-?data@MBinBuffer@@QEBAPEADXZ @1211 NONAME
+?data@MBinBuffer@@QEBAPEAEXZ @1211 NONAME
?isEmpty@MBinBuffer@@QEBA_NXZ @1212 NONAME
?length@MBinBuffer@@QEBA_KXZ @1213 NONAME
?remove@MBinBuffer@@QEAAX_K@Z @1214 NONAME
|