[fpc-pascal] GetMem should use out parameter ?

Skybuck Flying skybuck2000 at hotmail.com
Wed Aug 22 12:04:36 CEST 2007


Never mind.

I see what the problem is.

GetMem is actually a kind of (probably magical) wrapper around a memory 
manager.

The real GetMem is a function which returns a pointer.

As I already wrote, in Delphi an out of memory exception is raised.

The result value is thus never returned, which in this case means GetMem can 
not return a nil pointer.

And the result will be an uninitialized variable.

This creates a tiny little problem to get rid of the hint message.

It can probably easily be solved by writing:

Node := nil;
GetMem( Node, SizeOf(TNode) );

Bye,
  Skybuck. 




More information about the fpc-pascal mailing list