summaryrefslogtreecommitdiff
path: root/Kernel/KBufferBuilder.h
AgeCommit message (Collapse)Author
2022-05-06Kernel: Expose .length() of KBufferBuilderMacDue
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-01-12Kernel: Make Thread::backtrace() fallible using KStringIdan Horowitz
2021-11-17AK: Convert AK::Format formatting helpers to returning ErrorOr<void>Andreas Kling
This isn't a complete conversion to ErrorOr<void>, but a good chunk. The end goal here is to propagate buffer allocation failures to the caller, and allow the use of TRY() with formatting functions.
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-08Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>Andreas Kling
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace! This was a slightly tedious refactoring that took a long time, so it's not unlikely that some bugs crept in. Nevertheless, it does pass basic functionality testing, and it's just real nice to finally see the same pattern in all contexts. :^)
2021-09-08Kernel: Add KBuffer::bytes() and use itAndreas Kling
(Instead of hand-wrapping { data(), size() } in a bunch of places.)
2021-09-07Kernel: Make it possible for KBufferBuilder creation to failAndreas Kling
This patch adds KBufferBuilder::try_create() and treats it like anything else that can fail. And so, failure to allocate the initial internal buffer of the builder will now propagate an ENOMEM to the caller. :^)
2021-09-07Kernel: Make KBufferBuilder use KBuffer instead of KBufferImplAndreas Kling
This was the last remaining direct client of the KBufferImpl class outside of KBuffer.
2021-09-06Kernel: Make KBufferBuilder::append() & friends return KResultAndreas Kling
This allows callers to react to a failed append (due to OOM.)
2021-08-30Everywhere: Pass AK::Format TypeErasedFormatParams by referenceBrian Gianforcaro
This silences a overeager warning in sonar cloud, warning that slicing could occur with `VariadicFormatParams` which derives from `TypeErasedFormatParams`. Reference: https://sonarcloud.io/project/issues?id=SerenityOS_serenity&issues=AXuVPBO_k92xXUF3qWsm&open=AXuVPBO_k92xXUF3qWsm
2021-07-20Kernel: Remove KBufferBuilder's can_expand restrictionAndreas Kling
KBufferBuilder is always allowed to expand if it wants to. This restriction was added a long time ago when it was unsafe to allocate VM while generating ProcFS contents.
2021-07-20Kernel: Remove KBufferBuilder API for reusing an existing bufferAndreas Kling
This is not used anywhere anymore anyway.
2021-07-20Kernel: Remove confused comment in KBufferBuilder::appendff()Andreas Kling
KBufferBuilder exists for code that wants to build a KBuffer instead of a String. KBuffer is backed by anonymous VM, while String is backed by a kernel heap allocation.
2021-05-13Kernel: Avoid allocations in KBufferBuilder::appendffGunnar Beutner
This avoids some of the the shortest-lived allocations in the kernel: StringImpl::create_uninitialized(unsigned long, char*&) StringImpl::create(char const*, unsigned long, ShouldChomp) StringBuilder::to_string() const String::vformatted(StringView, TypeErasedFormatParams) void Kernel::KBufferBuilder::appendff<unsigned int>(...) JsonObjectSerializer<Kernel::KBufferBuilder>::add(..., unsigned int) Kernel::procfs$all(Kernel::InodeIdentifier, ...) const Kernel::procfs$all(Kernel::InodeIdentifier, Kernel::KBufferBuilder&)
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-28Kernel: Use default con/de-structorsBen Wiederhake
This may seem like a no-op change, however it shrinks down the Kernel by a bit: .text -432 .unmap_after_init -60 .data -480 .debug_info -673 .debug_aranges 8 .debug_ranges -232 .debug_line -558 .debug_str -308 .debug_frame -40 With '= default', the compiler can do more inlining, hence the savings. I intentionally omitted some opportunities for '= default', because they would increase the Kernel size.
2021-02-23AK+Kernel+Userland: Enable some more compiletime format string checksAnotherTest
This enables format string checks for three more functions: - String::formatted() - Builder::appendff() - KBufferBuilder::appendff()
2021-02-09Kernel: Convert all *Builder::appendf() => appendff()Andreas Kling
2021-01-03Kernel: Improve ProcFS behavior in low memory conditionsTom
When ProcFS could no longer allocate KBuffer objects to serve calls to read, it would just return 0, indicating EOF. This then triggered parsing errors because code assumed it read the file. Because read isn't supposed to return ENOMEM, change ProcFS to populate the file data upon file open or seek to the beginning. This also means that calls to open can now return ENOMEM if needed. This allows the caller to either be able to successfully open the file and read it, or fail to open it in the first place.
2020-12-18Kernel: Move KBufferBuilder to the fallible KBuffer APIAndreas Kling
KBufferBuilder::build() now returns an OwnPtr<KBuffer> and can fail. Clients of the API have been updated to handle that situation.
2020-11-02AK+Kernel: Escape JSON keys & valuesAndreas Kling
Grab the escaping logic from JSON string value serialization and use it for serializing all keys and values. Fixes #3917.
2020-10-08Kernel: Add KBufferBuilder::appendff.asynts
Why does this class exist anyways? What is wrong with using StringBuilder?
2020-09-25Meta+Kernel: Make clang-format-10 cleanBen Wiederhake
2020-02-16Kernel: Move all code into the Kernel namespaceAndreas Kling
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2019-09-06AK: Rename <AK/AKString.h> to <AK/String.h>Andreas Kling
This was a workaround to be able to build on case-insensitive file systems where it might get confused about <string.h> vs <String.h>. Let's just not support building that way, so String.h can have an objectively nicer name. :^)
2019-08-06Kernel: Add KBufferBuilder, similar to StringBuilder but for KBufferAndreas Kling
This class works by eagerly allocating 1MB of virtual memory but only adding physical pages on demand. In other words, when you append to it, its memory usage will increase by 1 page whenever you append across a page boundary (4KB.)