Initializing a pointer to an arraylist

I need to build some trie / tree and running into a problem.

Initially I need to build the tree with an owned childlist.
In a second phase I mark all identical subtrees (that I have got covered with hashing).
After de-duplication I need to reset the children pointer of nodes to the one and only unique children subtree.
After that I rebuild the tree (in a totally different memory layout)

I think I know how to relay that pointer, but how can I initialize the (owned) children safely?

const ChildList = std.ArrayListUnmanaged(Node);
pub const Node = struct
{
    // ... data
    is_reference: bool, // indicate we do not own this children anymore.
    children: *ChildList,

    pub init() Node
    {
        // now to init children safely.
    }
}

Does it need to be a pointer to ChildList? The array list will have an interior pointer, but the rest should be fine to have as part of thr struct. The easiest way is to remove the pointer and have it initialize with = .empty;

1 Like

Of course…! that must be possible.