The point is to make it work with pointers. Also, I found similar problem with C++. Its not working with Pascal, well, I prob. missed something.
1) I make types and variable for my pointers:
type
PReal = ^double;
PPReal = ^PReal;
var
data : ^PPReal;
GetMem( data, sizeof(PPReal)*x );
for i:=0 to x-1 do begin
GetMem( (data+i)^, sizeof(PReal)*y );
for j:=0 to y-1 do begin
GetMem( ((data+i)^+j)^, sizeof(real)*z );
end;
end;
for i:=0 to x-1 do begin
for j:=0 to y-1 do begin
Dispose( ((data+i)^+j) );
end;
Dispose( (data+i) );
end;
Dispose( data );
The last dispose is mirrored to its getmem, but the other two not. Fix that and it works:
for i:=0 to x-1 do begin
for j:=0 to y-1 do begin
writeln(i,' ',j,' *');
Dispose( ((data+i)^+j)^ );
end;
writeln(i,' ',j);
Dispose( (data+i)^ );
end;
Dispose( data );
p.s. freemem is the logical companion to getmem, as dispose is to new.