summaryrefslogtreecommitdiff
path: root/AK/MemoryStream.h
AgeCommit message (Collapse)Author
2022-11-26AK: Make it possible to not `using` AK classes into the global namespaceAndreas Kling
This patch adds the `USING_AK_GLOBALLY` macro which is enabled by default, but can be overridden by build flags. This is a step towards integrating Jakt and AK types.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-01-24Everywhere: Convert ByteBuffer factory methods from Optional -> ErrorOrSam Atkins
Apologies for the enormous commit, but I don't see a way to split this up nicely. In the vast majority of cases it's a simple change. A few extra places can use TRY instead of manual error checking though. :^)
2021-09-06Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safeAli Mohammad Pur
2021-08-08AK: Make `InputMemoryStream::read_LEB128_*` templatedDaniel Bertalan
On i686, reading integers larger than `2^32 - 1` would fail as the 32-bit `size_t` parameter would overflow. This caused us to read too few bytes in LibDebug's DWARF parser. Making this method templated solves this issue, as we now can call this API with a `u64` parameter.
2021-05-12Kernel+LibC: Make get_dir_entries syscall retriableMart G
The get_dir_entries syscall failed if the serialized form of all the directory entries together was too large to fit in its temporary buffer. Now the kernel uses a fixed size buffer, that is flushed to an output buffer when it is full. If this flushing operation fails because there is not enough space available, the syscall will return -EINVAL. That error code is then used in userspace as a signal to allocate a larger buffer and retry the syscall.
2021-05-04AK: Move the LEB128 logic to AK and make it usable with InputStreamAli Mohammad Pur
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2020-12-09AK: Fix offset calculation error in DuplexMemoryStream::write.asynts
2020-12-09AK: Fix unsigned integer underflow in DuplexMemoryStream::write.asynts
2020-12-08AK: Fix reading across chunks in DuplexMemoryStreamAnotherTest
2020-12-08AK: Implement DuplexMemoryStream::offset_of() in terms of memmem()AnotherTest
This fixes the FIXME about missing matches that go across chunk boundaries.
2020-11-24AK: Add IntrusiveList::take_last()Andreas Kling
2020-11-17AK: Fix OOB access in DuplexMemoryStream::offset_of()AnotherTest
This fixes an OOB access when the last read/written chunk is empty (as we _just_ started on a new chunk). Also adds a test case to TestMemoryStream. Found via human fuzzing in the shell: ```sh for $(cat /dev/urandom) { clear match $it { ?* as (x) { echo $x sleep 1 } } } ``` would assert at some point.
2020-11-13AK: Fix inverted condition in unsigned LEB128 decodeAndreas Kling
2020-11-08AK: Use reference algorithms for LEB128 parsingAndreas Kling
This fixes a bug in signed LEB128 parsing (sign extension stage) which would sometimes cause debug info to look very strange.
2020-09-21LibAudio: Use InputMemoryStream instead of BufferStream.asynts
2020-09-21AK: Add OutputMemoryStream::is_end.asynts
2020-09-15AK: Add OutputMemoryStream::fill_to_end.asynts
2020-09-15AK: Re-add OutputMemoryStream for static buffers only.asynts
2020-09-15AK: Remove OutputMemoryStream for DuplexMemoryStream.asynts
OutputMemoryStream was originally a proxy for DuplexMemoryStream that did not expose any reading API. Now I need to add another class that is like OutputMemoryStream but only for static buffers. My first idea was to make OutputMemoryStream do that too, but I think it's much better to have a distinct class for that. I originally wanted to call that class FixedOutputMemoryStream but that name is really cumbersome and it's a bit unintuitive because InputMemoryStream is already reading from a fixed buffer. So let's just use DuplexMemoryStream instead of OutputMemoryStream for any dynamic stuff and create a new OutputMemoryStream for static buffers.
2020-09-14AK: Lower the requirements for InputStream::eof and rename it.asynts
Consider the following snippet: void foo(InputStream& stream) { if(!stream.eof()) { u8 byte; stream >> byte; } } There is a very subtle bug in this snippet, for some input streams eof() might return false even if no more data can be read. In this case an error flag would be set on the stream. Until now I've always ensured that this is not the case, but this made the implementation of eof() unnecessarily complicated. InputFileStream::eof had to keep a ByteBuffer around just to make this possible. That meant a ton of unnecessary copies just to get a reliable eof(). In most cases it isn't actually necessary to have a reliable eof() implementation. In most other cases a reliable eof() is avaliable anyways because in some cases like InputMemoryStream it is very easy to implement.
2020-09-11AK: Calculate the chunk index correctly in DuplexMemoryStream.asynts
2020-09-06Streams: Consistent behaviour when reading from stream with error.asynts
The streaming operator doesn't short-circuit, consider the following snippet: void foo(InputStream& stream) { int a, b; stream >> a >> b; } If the first read fails, the second is called regardless. It should be well defined what happens in this case: nothing.
2020-09-01AK: Add OutputMemoryStream class.asynts
2020-09-01AK: Add DuplexMemoryStream::copy_into_contiguous_buffer.asynts
2020-09-01AK: Move memory streams into their own header.asynts