Write Writes data to the write pointer and adjusts the write pointer. PARAM: pbBuffer - pointer to the buffer to receive write data count - the number of bytes to write RETURN: The actual number of bytes written ************************************************/
| 204 | The actual number of bytes written |
| 205 | ************************************************/ |
| 206 | int CUT_FIFO_Queue::Write(LPBYTE pbBuffer, unsigned int count) { |
| 207 | |
| 208 | int nNumToWrite = (std::min)(GetFreeSize(), (int)count); |
| 209 | int nNumWritten = 0; |
| 210 | |
| 211 | if(m_iWritePointer + nNumToWrite > m_cbBuffer) { |
| 212 | |
| 213 | int nNumAtEnd = m_cbBuffer - m_iWritePointer; |
| 214 | |
| 215 | memcpy(m_pbBuffer + m_iWritePointer, pbBuffer, nNumAtEnd); |
| 216 | nNumWritten += nNumAtEnd; |
| 217 | nNumToWrite -= nNumAtEnd; |
| 218 | m_iWritePointer = 0 ; |
| 219 | } |
| 220 | |
| 221 | memcpy(m_pbBuffer + m_iWritePointer, pbBuffer + nNumWritten, nNumToWrite); |
| 222 | |
| 223 | nNumWritten += nNumToWrite; |
| 224 | m_iWritePointer += nNumToWrite; |
| 225 | |
| 226 | return nNumWritten; |
| 227 | } |
nothing calls this directly
no outgoing calls
no test coverage detected