(memory_stream.c) Cleanup

This commit is contained in:
twinaphex 2015-09-13 09:45:41 +02:00
parent b5f7ccab22
commit eccda8c39a

View File

@ -100,14 +100,21 @@ size_t memstream_write(memstream_t *stream, const void *data, size_t bytes)
int memstream_seek(memstream_t *stream, int offset, int whence)
{
size_t ptr;
if (whence == SEEK_SET)
ptr = offset;
else if (whence == SEEK_CUR)
ptr = stream->m_ptr + offset;
else if (whence == SEEK_END)
ptr = stream->m_size + offset;
else
return -1;
switch (whence)
{
case SEEK_SET:
ptr = offset;
break;
case SEEK_CUR:
ptr = stream->m_ptr + offset;
break;
case SEEK_END:
ptr = stream->m_size + offset;
break;
default:
return -1;
}
if (ptr <= stream->m_size)
{