Refactor: Replace malloc roots with std::vector