mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-26 06:20:16 -04:00
fix setting EOF in memio (#1059)
This commit is contained in:
parent
3483ac7a96
commit
feb602580e
16
src/memio.c
16
src/memio.c
@ -71,22 +71,24 @@ size_t mem_fread(void *buf, size_t size, size_t nmemb, MEMFILE *stream)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stream->read_eof)
|
|
||||||
{
|
|
||||||
stream->eof = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Trying to read more bytes than we have left?
|
// Trying to read more bytes than we have left?
|
||||||
|
|
||||||
items = nmemb;
|
items = nmemb;
|
||||||
|
|
||||||
if (items * size > stream->buflen - stream->position)
|
if (items * size > stream->buflen - stream->position)
|
||||||
{
|
{
|
||||||
|
if (stream->read_eof)
|
||||||
|
{
|
||||||
|
stream->eof = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stream->read_eof = true;
|
||||||
|
}
|
||||||
|
|
||||||
items = (stream->buflen - stream->position) / size;
|
items = (stream->buflen - stream->position) / size;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream->read_eof = (items > 0 ? false : true);
|
|
||||||
|
|
||||||
// Copy bytes to buffer
|
// Copy bytes to buffer
|
||||||
|
|
||||||
memcpy(buf, stream->buf + stream->position, items * size);
|
memcpy(buf, stream->buf + stream->position, items * size);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user