[fpc-pascal] How to allocate a 2D array?
Arjan van Dijk
Arjan.van.Dijk at rivm.nl
Mon Jan 12 14:35:36 CET 2009
Hi!
In my code I often use 2D arrays.
Until today, I kept the maximum dimension fixed to 400 * 300 points.
How can I make allocatable columns of ARBITRARY size?
For simplicity here a 1D reduction of the problem:
This is what I have:
CONST
MaxN = 400;
TYPE
ColumnType = ARRAY[1..MaxN] OF Float;
Recently, some of my grids were so large that having all my grids use the
same maximum size
would cost too much memory. Therefore, I would like to dynamically
allocate space
when the actual dimensions of a grid are known. I found:
TYPE
ColumnTypePtr = ^ColumnType;
VAR
Column : ColumnTypePtr;
...
NEW(Column);
and now I have a column of size 400.
--> Question: How can I make allocatable columns of ARBITRARY size?
Thanks,
Arjan
Disclaimer RIVM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20090112/b8f42c4d/attachment.html>
More information about the fpc-pascal
mailing list