[fpc-devel] I get duplicate GUIDs under Linux

Vincent Snijders vsnijders at quicknet.nl
Mon Jun 2 16:46:43 CEST 2008

Klaus Hartnegg schreef:
>> a call to randomize "disrupts" the current state of the random 
>> generator. That means that if you use random outside guid creation, 
>> creating a guid can have unintended side effects on your random 
>> generation.
> Maybe the GUID generator should have an automatic call to randomize,
> but use its own randseed (or preserve the original value):
> randseed_old := randseed;
> if not guid_rnd_initialized then begin
>    randomize;
>    guid_rnd_initialized := true;
> end
> else
>    randseed := guid_randseed;
> result := rnd2guid(random);
> guid_randseed := randseed;
> randseed := randseed_old;

It is not that easy to restore the state of random number generator.


More information about the fpc-devel mailing list