Read Reads data from the read pointer and adjusts the read pointer. PARAM: pbBuffer - pointer to the buffer to receive read data count - the number of bytes to read RETURN: The actual number of bytes read ************************************************/
| 136 | The actual number of bytes read |
| 137 | ************************************************/ |
| 138 | int CUT_FIFO_Queue::Read(LPBYTE pbBuffer, unsigned int count) { |
| 139 | |
| 140 | int nNumToRead = (std::min)(GetDataSize(), (int)count); |
| 141 | int nNumRead = 0; |
| 142 | |
| 143 | if(m_iReadPointer + nNumToRead > m_cbBuffer) { |
| 144 | |
| 145 | int nNumAtEnd = m_cbBuffer - m_iReadPointer; |
| 146 | |
| 147 | memcpy(pbBuffer, m_pbBuffer + m_iReadPointer, nNumAtEnd); |
| 148 | nNumRead += nNumAtEnd; |
| 149 | nNumToRead -= nNumAtEnd; |
| 150 | m_iReadPointer = 0 ; |
| 151 | } |
| 152 | |
| 153 | memcpy(pbBuffer + nNumRead, m_pbBuffer + m_iReadPointer, nNumToRead); |
| 154 | |
| 155 | nNumRead += nNumToRead; |
| 156 | m_iReadPointer += nNumToRead; |
| 157 | |
| 158 | return nNumRead; |
| 159 | } |
| 160 | |
| 161 | /*********************************************** |
| 162 | Peek |
nothing calls this directly
no outgoing calls
no test coverage detected