Function reserve_arena

Synopsis

#include <src/c4/yml/tree.hpp>

void reserve_arena(size_t arena_cap)

Description

ensure the tree's internal string arena is at least the given capacity

Note
Growing the arena may cause relocation of the entire existing arena, and thus change the contents of individual nodes.

Source

Lines 979-994 in src/c4/yml/tree.hpp.

void reserve_arena(size_t arena_cap)
{
    if(arena_cap > m_arena.len)
    {
        substr buf;
        buf.str = (char*) m_alloc.allocate(arena_cap, m_arena.str);
        buf.len = arena_cap;
        if(m_arena.str)
        {
            RYML_ASSERT(m_arena.len >= 0);
            _relocate(buf); // does a memcpy and changes nodes using the arena
            m_alloc.free(m_arena.str, m_arena.len);
        }
        m_arena = buf;
    }
}





Add Discussion as Guest

Log in