1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 06:47:34 +00:00

AK: Return KString instead of String from encode_hex in the Kernel

This let's us propagate allocation errors from this API.
This commit is contained in:
Idan Horowitz 2022-02-15 23:25:25 +02:00 committed by Andreas Kling
parent d296001f3f
commit 3219ce3d61
3 changed files with 32 additions and 6 deletions

View file

@ -8,9 +8,14 @@
#include <AK/ByteBuffer.h>
#include <AK/Error.h>
#include <AK/String.h>
#include <AK/StringView.h>
#ifdef KERNEL
# include <Kernel/KString.h>
#else
# include <AK/String.h>
#endif
namespace AK {
constexpr u8 decode_hex_digit(char digit)
@ -26,7 +31,11 @@ constexpr u8 decode_hex_digit(char digit)
ErrorOr<ByteBuffer> decode_hex(StringView);
#ifdef KERNEL
ErrorOr<NonnullOwnPtr<Kernel::KString>> encode_hex(ReadonlyBytes);
#else
String encode_hex(ReadonlyBytes);
#endif
}