| 181 | } |
| 182 | |
| 183 | void* ChunkedDataBuffer::FastRead(void * data, int size) |
| 184 | { |
| 185 | // Fast case- no crossing chunk boundary |
| 186 | if (mReadCurPtr + size <= mReadNextAlloc) |
| 187 | { |
| 188 | void* retVal = mReadCurPtr; |
| 189 | mReadCurPtr += size; |
| 190 | return retVal; |
| 191 | } |
| 192 | |
| 193 | void* dataHead = data; |
| 194 | while (mReadCurPtr + size > mReadNextAlloc) |
| 195 | { |
| 196 | int curSize = (int)(mReadNextAlloc - mReadCurPtr); |
| 197 | if (curSize > 0) |
| 198 | memcpy(data, mReadCurPtr, curSize); |
| 199 | |
| 200 | NextReadPool(); |
| 201 | data = (uint8*)data + curSize; |
| 202 | size -= curSize; |
| 203 | } |
| 204 | |
| 205 | memcpy(data, mReadCurPtr, size); |
| 206 | mReadCurPtr += size; |
| 207 | return dataHead; |
| 208 | } |
| 209 | |
| 210 | uint8 ChunkedDataBuffer::Read() |
| 211 | { |