Skip to content

Commit

Permalink
LibC: Implement __freadptrinc
Browse files Browse the repository at this point in the history
  • Loading branch information
timschumi authored and awesomekling committed Apr 3, 2022
1 parent 89ed064 commit 4f706d8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions Userland/Libraries/LibC/bits/stdio_file_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ struct FILE {
void reopen(int fd, int mode);

u8 const* readptr(size_t& available_size);
void readptr_increase(size_t increment);

enum Flags : u8 {
None = 0,
Expand Down
14 changes: 14 additions & 0 deletions Userland/Libraries/LibC/stdio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,11 @@ u8 const* FILE::readptr(size_t& available_size)
return m_buffer.begin_dequeue(available_size);
}

void FILE::readptr_increase(size_t increment)
{
m_buffer.did_dequeue(increment);
}

FILE::Buffer::~Buffer()
{
if (m_data_is_malloced)
Expand Down Expand Up @@ -1355,6 +1360,15 @@ char const* __freadptr(FILE* stream, size_t* sizep)
*sizep = available_size;
return reinterpret_cast<char const*>(ptr);
}

void __freadptrinc(FILE* stream, size_t increment)
{
VERIFY(stream);

ScopedFileLock lock(stream);

stream->readptr_increase(increment);
}
}

template bool FILE::gets<u8>(u8*, size_t);
Expand Down
1 change: 1 addition & 0 deletions Userland/Libraries/LibC/stdio_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ void __fpurge(FILE*);

size_t __freadahead(FILE*);
char const* __freadptr(FILE*, size_t*);
void __freadptrinc(FILE*, size_t);

__END_DECLS

0 comments on commit 4f706d8

Please sign in to comment.