On Thu, Jun 19, 2014 at 03:28:42PM +0200, Sven Barth wrote:
On 19.06.2014 13:29, Karoly Balogh (Charlie/SGR) wrote:
So either you use mypointer:=GetMem(size); or GetMem(mypointer, size);
both are valid. If you need to allocate heap space for a record,
use New/Dispose, or GetMem(myptr, sizeof(Tmyrecord));

I wouldn't use GetMem() in case of record pointers just in case a managed type happens to be in there. Unlike GetMem() New() does initialize those fields correctly. Alternatively one should use Initialize(myptr^) after the call to GetMem().


I seem to remember being warned in the old days of Turbo Pascal not mix use of getmem()/freemem() and new()/dispose() within a program, due to differences in the memory allocation strategies. Are there still any compatibility or efficiency/performance issues with alternating between these two families, or can the most simple or appropriate call be used interchangeably? In other words, now that objects are so much more prevalent in Pascal code, should getmem() and freemem() be avoided?

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to