Warning_C4267_'argument': conversion from 'size_t' to 'unsigned int', possible loss of data

  • Thread starter Thread starter David student
  • Start date Start date
D

David student

Guest
Hello,

I am getting the below compilation warning message,

Warning C4267 'argument': conversion from 'size_t' to 'unsigned int', possible loss of data

from the second parameter of the below function call:

SetAdditionalDataToSend((BYTE *)(ws2s(postdatapaylod)).c_str(), (ws2s(postdatapaylod)).size())

Below is the complete code:

void MyHttpClient::setDataToSend(wstring postdatapaylod)
{
pSubscriptionClient->m_sDataToSend = postdatapaylod;
if (!pSubscriptionClient->SetAdditionalDataToSend((BYTE *)(ws2s(postdatapaylod)).c_str(), (ws2s(postdatapaylod)).size()))
MyLog(L"setDataToSend Failed");
}

bool MyHttpClient::SetAdditionalDataToSend(BYTE *data, unsigned int dataSize)
{
if (data == NULL || dataSize < 0)
{
return false;
}

if (m_pDataToSend != NULL)
{
delete[] m_pDataToSend;
}
m_pDataToSend = NULL;
m_pDataToSend = new BYTE[dataSize];
if (m_pDataToSend != NULL)
{
memcpy_s(m_pDataToSend, dataSize, data, dataSize);
m_dataToSendSize = dataSize;
return true;
}

return false;
}

string MyHttpClient::ws2s(const std::wstring & wstr)
{
using convert_typeX = std::codecvt_utf8<wchar_t>;
std::wstring_convert<convert_typeX, wchar_t> converterX;
return converterX.to_bytes(wstr);
}

SubscriptionClient *pSubscriptionClient;
wstring m_sDataToSend;

Can someone explain me how to resolve this warning message?

Regards

Continue reading...
 
Back
Top