1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| int CDataBuffer::SaveData(char *pData)
{
int retValue = DB_SUCCESS;
if (strlen(pData) > (MAX_STRING_SIZE- 1)) return DB_TO_LONG;
WaitForSingleObject(m_hMutex, INFINITE);
if ((m_pInPos == m_pOutPos) && (m_nbrItems > 0)) retValue = DB_OVERFLOW;
if (retValue == DB_SUCCESS)
{
strcpy(&m_pBuffer[m_pInPos][0], pData);
// Check if buffer should be wrapped around.
if (m_pInPos < (BUFFER_SIZE - 1))
{
m_pInPos++;
}
else
{
m_pInPos = 0;
}
m_nbrItems++;
}
ReleaseMutex(m_hMutex);
return retValue;
} |
Partager