Peek Reads data from the read pointer but does not adjust 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 ************************************************/
| 170 | The actual number of bytes read |
| 171 | ************************************************/ |
| 172 | int CUT_FIFO_Queue::Peek(LPBYTE pbBuffer, unsigned int count) { |
| 173 | |
| 174 | int iReadPointer = m_iReadPointer; |
| 175 | int nNumToRead = (std::min)(GetDataSize(), (int)count); |
| 176 | int nNumRead = 0; |
| 177 | |
| 178 | if(iReadPointer + nNumToRead > m_cbBuffer) { |
| 179 | |
| 180 | int nNumAtEnd = m_cbBuffer - iReadPointer; |
| 181 | |
| 182 | memcpy(pbBuffer, m_pbBuffer + iReadPointer, nNumAtEnd); |
| 183 | nNumRead += nNumAtEnd; |
| 184 | nNumToRead -= nNumAtEnd; |
| 185 | iReadPointer = 0 ; |
| 186 | } |
| 187 | |
| 188 | memcpy(pbBuffer + nNumRead, m_pbBuffer + iReadPointer, nNumToRead); |
| 189 | |
| 190 | nNumRead += nNumToRead; |
| 191 | |
| 192 | return nNumRead; |
| 193 | } |
| 194 | |
| 195 | /*********************************************** |
| 196 | Write |
nothing calls this directly
no outgoing calls
no test coverage detected