POSIX initstate() 函数是否考虑了传递的状态数组中的数据?

Does the POSIX initstate() function take into account the data in the passed state array?

char *initstate(unsigned int seed, char *state, size_t n);

在调用 initstate() 之前,我是否应该用一些数据填充 state[] 数组? initstate 函数会忽略状态数组的全部内容吗?只有提供的 sizeseed 重要吗? initstate的目的是填充state[]数组而不考虑其当前内容吗?

我在网上看到至少 1 个示例,在调用 initstate 之前填充 state[] 数组。 -- 我找不到 url,抱歉。 -- 但是,我的经验表明,只要种子保持不变,state[] 数组的(先前)内容就无关紧要。根据 random() 函数产生的连续随机数。

initstate() function "allows a state array state to be initialized for use by random()". In other words, initstate() will write a new state into the passed state buffer and then set it as the current internal state which will be used (and updated) by subsequent random() calls. This can also be seen in the glibc source。另一方面,setstate() 函数采用已经初始化的 state 并将其设置为内部状态 原样 .

Is the purpose of initstate to fill the state[] array without taking into account its current content?

是的,正确。

I have seen at least 1 example on the net, filling the state[] array before initstate call. [...] my experience shows that as long as the seed remains the same, the (previous) content of the state[] array does not matter.

你说得对,那是不需要的。数组中的数据无关紧要,将被覆盖。