void reserve_buffers(ctx_t &ctx)
{
    kernel_buffers_t &kbufs = ctx.dc_buffers;
    allocator_t &alc = ctx.dc_allocator;
    const tagver_t maxver = ctx.dfa.maxtagver;
    const size_t nkern = ctx.state.size();

    if (kbufs.maxsize < nkern) {
        kbufs.maxsize = nkern * 2; // in advance
        kbufs.kernel = make_new_kernel<stadfa>(kbufs.maxsize, alc);
    }

    // +1 to ensure max tag version is not forgotten in loops
    kbufs.max = maxver + 1;
    if (kbufs.cap < kbufs.max) {
        kbufs.cap = kbufs.max * 2; // in advance

        const size_t n = static_cast<size_t>(kbufs.cap);
        kbufs.indegree = alc.alloct<uint32_t>(n);

        if (!stadfa) {
            kbufs.x2y = alc.alloct<tagver_t>(n);
            kbufs.y2x = alc.alloct<tagver_t>(n);
            kbufs.x2t = alc.alloct<size_t>(n);
            kbufs.backup_actions = alc.alloct<tcmd_t>(n);
        }
    }
}
void reserve_buffers(ctx_t &ctx)
{
    kernel_buffers_t &kbufs = ctx.dc_buffers;
    allocator_t &alc = ctx.dc_allocator;
    const tagver_t maxver = ctx.dfa.maxtagver;
    const size_t nkern = ctx.state.size();

    if (kbufs.maxsize < nkern) {
        kbufs.maxsize = nkern * 2;  
        kbufs.kernel = make_new_kernel<stadfa>(kbufs.maxsize, alc);
    }

     
    kbufs.max = maxver + 1;
    if (kbufs.cap < kbufs.max) {
        kbufs.cap = kbufs.max * 2;  

        const size_t n = static_cast<size_t>(kbufs.cap);
        kbufs.indegree = alc.alloct<uint32_t>(n);

        if (!stadfa) {
            kbufs.x2y = alc.alloct<tagver_t>(n);
            kbufs.y2x = alc.alloct<tagver_t>(n);
            kbufs.x2t = alc.alloct<size_t>(n);
            kbufs.backup_actions = alc.alloct<tcmd_t>(n);
        }
    }
}