[fpc-pascal] allocating memory for records
vsnijders at quicknet.nl
Fri Jul 7 19:00:19 CEST 2006
Marc Santhoff wrote:
> excuse me for asking dumb questions, but over using objects only for
> years I forgot:
> If I need to allocate memory for a record type variable, what functions
> should get used?
> Is the GetMem/FreeMem pair okay or is there something more appropriate?
> x: PMyRec
> GetMem(x, sizeof(x));
> would be my best guess atm.
> And another related question:
> If a record has a String field, how is memory allacation handled?
> MyRec = record
> a: integer; /* very clear */
> b: string; /* not clear, how much bytes are needed? */
I would use:
I guess the memory will initialized and finalized for strings correctly
in that case too, but I am not sure;
More information about the fpc-pascal