Function copy_to_arena
Synopsis
#include <src/c4/yml/tree.hpp>
substr copy_to_arena(csubstr s)
Description
copy the given substr to the tree's arena, growing it by the required size
- Note
- Growing the arena may cause relocation of the entire existing arena, and thus change the contents of individual nodes.
- See
- alloc_arena()
Source
Lines 947-962 in src/c4/yml/tree.hpp.
substr copy_to_arena(csubstr s)
{
substr cp = alloc_arena(s.len);
RYML_ASSERT(cp.len == s.len);
RYML_ASSERT(!s.overlaps(cp));
#if (!defined(__clang__)) && (defined(__GNUC__) && __GNUC__ >= 10)
C4_SUPPRESS_WARNING_GCC_PUSH
C4_SUPPRESS_WARNING_GCC("-Wstringop-overflow=") // no need for terminating \0
C4_SUPPRESS_WARNING_GCC( "-Wrestrict") // there's an assert to ensure no violation of restrict behavior
#endif
memcpy(cp.str, s.str, s.len);
#if (!defined(__clang__)) && (defined(__GNUC__) && __GNUC__ >= 10)
C4_SUPPRESS_WARNING_GCC_POP
#endif
return cp;
}