Created
November 21, 2011 20:43
-
-
Save rygorous/1383867 to your computer and use it in GitHub Desktop.
Read implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ErrorCode Read(BufferedStream *s, void *buffer, size_t numBytes) | |
{ | |
U8 *dest = (U8 *)buffer; | |
while (numBytes) { | |
if (s->cursor == s->end) | |
s->Refill(s); | |
size_t count = min(numBytes, (size_t)(s->end - s->cursor)); | |
memcpy(dest, s->cursor, count); | |
dest += count; | |
s->cursor += count; | |
numBytes -= count; | |
} | |
return s->error; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment