[fpc-devel] I get duplicate GUIDs under Linux

Graeme Geldenhuys graemeg.lists at gmail.com
Thu May 29 14:59:10 CEST 2008


2008/5/29 Michael Van Canneyt <michael at freepascal.org>:
>
> can you send me your test program, so I can test my fixes ?


Here you go. It is pretty much what I sent before, except now I made
it a console application instead of a fpGUI one. Below it tries to
create 50,000 GUID's. My SQL version tries 5mil.


-------------------------[ project1.pas ]----------------------------------
program Project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes, SysUtils;


procedure GUIDTest;
var
  sl: TStringList;
  s: string;
  i: integer;
  d: integer;
  guid: TGUID;
begin
  sl := TStringList.Create;
  try
    try
      sl.Sorted := True;
      sl.Duplicates := dupError;
      for i := 1 to 50000 do
      begin
        CreateGUID(guid);
        s := GUIDToString(guid);
        sl.Add(s);
//        sl.Add(IntToStr(i) + s);
      end;
      writeln('Created ', sl.Count, ' GUIDs');
    except
      on e: EStringListError do
      begin
        writeln('Duplicate value detected: ' + s);
        writeln('  List.Count = ', sl.Count);
      end;
      on e: Exception do
        writeln('Unknown error: ', e.Message);
    end;
  finally
    sl.Free;
  end;
end;

begin
  GUIDTest;
end.

------------------------------[ end ]-----------------------------------



Regards,
 - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-devel mailing list