The use of get_randstate() and set_randstate()

It’s used to ensure random stability in the current process(thread). A RNG is used up for each class constructed by the current thread. By wrapping the the construction of m_cfg_dap around a set/get, you are protecting the random stability of the thread calling the function free. It usually used when inserting debug code so the construction of extra class object does not disturb the code that follows it. Whether it’s really needed here is hard to know without seeing more code.