Jakub Jelinek wrote:
On Fri, May 19, 2006 at 03:54:26PM +0100, Matt Davey wrote:
On Fri, 2006-05-19 at 10:20 -0400, Jakub Jelinek wrote:
On Fri, May 19, 2006 at 04:16:40PM +0200, BankHacker wrote:
Jakub, I have tried to do what you propose but the following code is
throwing an error in execution time:
[...]
memset(randomdataState, 0, sizeof(*randomdataState));
And you dereference the uninitialized pointer here ^^^.
Umm, just to be pedantic, sizeof will happily return
the number of bytes required to store 'struct random_data'. It doesn't
need to dereference anything. eg. "sizeof(struct random_data)"
The problem is already in that memset, not on the third memset
argument, but the first. The dereference is done in memset, not in the
caller.
Jakub
I went and read man rand and it was interesting. I'm not sure if the
random number needs to be a true random or if a pseudo-random will work.
The function:
int rand(void)
will provide pseudo random numbers between 0 and RAND_MAX. You can make
it better if you you use srand() to generate a starting number for rand.
Karl