1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:04:59 +00:00

LibC: Implement __freadptr

This commit is contained in:
Tim Schumacher 2021-11-07 17:09:51 +01:00 committed by Andreas Kling
parent 8da0cf7912
commit 9b543ddb16
3 changed files with 26 additions and 0 deletions

View file

@ -369,6 +369,11 @@ void FILE::reopen(int fd, int mode)
m_eof = false;
}
u8 const* FILE::readptr(size_t& available_size)
{
return m_buffer.begin_dequeue(available_size);
}
FILE::Buffer::~Buffer()
{
if (m_data_is_malloced)
@ -1322,6 +1327,23 @@ void __fpurge(FILE* stream)
ScopedFileLock lock(stream);
stream->purge();
}
char const* __freadptr(FILE* stream, size_t* sizep)
{
VERIFY(stream);
VERIFY(sizep);
ScopedFileLock lock(stream);
size_t available_size;
u8 const* ptr = stream->readptr(available_size);
if (available_size == 0)
return nullptr;
*sizep = available_size;
return reinterpret_cast<char const*>(ptr);
}
}
template bool FILE::gets<u8>(u8*, size_t);