[fpc-devel] I get duplicate GUIDs under Linux

Klaus Hartnegg hartnegg at gmx.de
Mon Jun 2 16:44:26 CEST 2008


On Mon, 2 Jun 2008, Daniƫl Mantione wrote:

> Op Mon, 2 Jun 2008, schreef Michael Van Canneyt:
>
>> Creating GUIDs should never be deterministic.. ?
>
> 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;


More information about the fpc-devel mailing list