Add arena_copy and lfstr_copy_arena #8
Loading…
Reference in a new issue
No description provided.
Delete branch "fputs/arena-copy"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds
arena_copyandlfstr_copy_arena.arena_copycopiesnbytes into a fresh arena block.n == 0copies nothing and still returns a non-NULL pointer.arena_malloc(0)does not advance the bump pointer, so a zero-length copy reserves one byte and must not be read.lfstr_copy_arenais declared inlfstring.hand defined insrc/string.c. It copiess.nbytes even when a NUL sits in the middle, then writes one trailing NUL that is not counted inn. Failure leaves*outunchanged.The test uses
arena_init_bufwith a slab too small for the second copy.arena_freedoes not free that caller-owned slab.Tested with
-DCMAKE_BUILD_TYPE=Debug -DFLINT_SANITIZE=ON -DCMAKE_C_EXTENSIONS=OFF.ctest --label-exclude slow: 25/25 passed.