From 02d56e83931e53e1cde57247c64d56fda3804f77 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 1 Dec 2023 20:39:44 -0500 Subject: [WIP] Tighten up reader node management [WIP] Broken on 32-bit This makes the reader stack manipulations stricter, to make the code more regular and avoid redundant work and bad cache activity. Now, functions that push node headers and their bodies are responsible for (more or less) immediately pushing any trailing null bytes required for termination and alignment. This makes the writes to the node in the stack more local, ensures nodes are terminated as early as possible (to reduce the risk of using non-terminated strings), and avoids the need to calculate aligned stack allocations. --- src/read_utf8.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/read_utf8.c') diff --git a/src/read_utf8.c b/src/read_utf8.c index 4639c34e..5b1f737c 100644 --- a/src/read_utf8.c +++ b/src/read_utf8.c @@ -70,15 +70,15 @@ read_utf8_code_point(SerdReader* const reader, uint32_t* const code, const uint8_t lead) { - uint8_t size = 0U; - uint8_t bytes[MAX_UTF8_BYTES] = {lead, 0U, 0U, 0U}; + SerdStatus st = SERD_SUCCESS; + uint8_t size = 0U; + uint8_t bytes[MAX_UTF8_BYTES] = {lead, 0U, 0U, 0U}; *code = 0U; skip_byte(reader, lead); - SerdStatus st = read_utf8_continuation_bytes(reader, bytes, &size, lead); - if (st) { + if ((st = read_utf8_continuation_bytes(reader, bytes, &size, lead))) { return reader->strict ? st : push_bytes(reader, dest, replacement_char, 3); } -- cgit v1.2.1