I got this question from a Delphi 2006 user regarding a code change I made in the tiOPF project. tiOPF is compiled with FPC using the Delphi compiler mode. FPC 2.0.4 and FPC 2.1.1 is used.
--------------------------------------------- procedure tiGetPropertyNames(AClass : TtiBaseObjectClass; AStringList : TStringList; APropFilter : TTypeKinds = ctkSimple); var lCount : integer; lSize : integer; lList : PPropList; i : integer; lPropFilter : TTypeKinds; begin lList := nil; // <<== New line, I expect to fix a FPC warning ... GetMem(lList, lSize); But it's created a warning in BDS2006 Variable assigned to LList never used --------------------------------------------- Quote from the FPC's GetMem help: Getmem reserves Size bytes memory on the heap, and returns a pointer to this memory in p. If no more memory is available, nil is returned. Quote from Kylix 3 help: If there isn't enough memory available to allocate the dynamic variable, an EOutOfMemory exception is raised. Question 1: I set lList := nil; to get rid of a FPC compiler warning saying I am using a variable that hasn't been initialized. Is that warning needed in such a case, because GetMem will initialize it for me, correct? Ignoring the compiler warning is also a option I guess. :) Question 2: Reading the help, I thought there would be no harm setting lList := nil, because if there is no memory available, GetMem would set it to nil as well. But this brings me to the second question. Under Delphi and Kylix, an EOutOfMemory exception is raised, but under FPC the pointer is set to nil. Does FPC also raise an EOutOfMemory exception? If it does, the help doesn't mention it. -- Graeme Geldenhuys Location: S 34° 03.168' E018° 49.342' http://tinyurl.com/y6lc26 There's no place like 127.0.0.1 _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal