diff options
author | David Robillard <d@drobilla.net> | 2023-12-01 20:39:44 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:08 -0500 |
commit | 02d56e83931e53e1cde57247c64d56fda3804f77 (patch) | |
tree | 2d1ac467bc56f4f4f3570497427be32d7e36bd1a /src/node.c | |
parent | d094448c095a59117febc8bd4687df071ce9759a (diff) | |
download | serd-02d56e83931e53e1cde57247c64d56fda3804f77.tar.gz serd-02d56e83931e53e1cde57247c64d56fda3804f77.tar.bz2 serd-02d56e83931e53e1cde57247c64d56fda3804f77.zip |
[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.
Diffstat (limited to 'src/node.c')
-rw-r--r-- | src/node.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -229,7 +229,7 @@ serd_node_set(ZixAllocator* const allocator, which must be normalized before being passed to a sink so comparison will work correctly. */ -void +static void serd_node_zero_pad(SerdNode* node) { char* buf = serd_node_buffer(node); @@ -274,6 +274,8 @@ serd_node_construct_simple(const size_t buf_size, } serd_node_zero_pad(node); + assert(total_size % sizeof(SerdNode) == 0); + return result(SERD_SUCCESS, total_size); } @@ -612,7 +614,7 @@ serd_node_new(ZixAllocator* const allocator, const SerdNodeArgs args) assert(r.count % sizeof(SerdNode) == 0); SerdNode* const node = - serd_node_malloc(allocator, sizeof(SerdNode) + r.count + 1); + serd_node_malloc(allocator, sizeof(SerdNode) + r.count); if (node) { r = serd_node_construct(r.count, node, args); |