procedure GetMem (var p: Pointeger; Size: Cardinal);
Allocates dynamical storage on the heap and returns a pointer to it in p.
Since Extended Pascal's schemata provide a cleaner way to implement dynamical arrays and such, we recommend using GetMem and FreeMem only for low-level applications.
GetMem is a Borland Pascal extension.
The Borland-comatibility unit Graph from the BPcompat package supports a GetImage and a PutImage procedure which need a variable of size ImageSize as a buffer. Since these are “black box” routines, the buffer can't reasonably be a schema providing a dynamical array. Instead, we have to use GetMem and FreeMem for dynamical memory allocation.
program GetMemDemo; var Buffer: Pointer; Size: Cardinal; begin Size := Random (10000); { the size can be determined at run time } GetMem (Buffer, Size); { Do something with Buffer } FreeMem (Buffer) { or: FreeMem (Buffer, Size) } end.