[fpc-pascal] multidimensional dynarrays SetLenght and memory layout

Marc Santhoff M.Santhoff at t-online.de
Sat Sep 16 13:26:02 CEST 2006


Am Samstag, den 16.09.2006, 09:45 +0200 schrieb Florian Klaempfl:
> Marc Santhoff schrieb:
> > Hi,
> > 
> > since I managed to get static arrays handed over to a C library I want
> > to know if this is possible for dynamic arrays too.
> > 
> > I browsed the docs and source but I'm not able to find the actual
> > implementation of the SetLength() procedure for dynarrays. 
> 
> rtl/inc/dynarr.inc

I had looked at that one, but didn't understand ...

> > Where is it
> > or maybe better: how does it work?
> > 
> > I think I'll know when the first question is answered, but: how is the
> > memory for dynamic arrays handled, is there a chance of forcing it to be
> > one continuous block on the heap for giving a pointer to it to an
> > external function?
> 
> No. Dyn. arrays involve several compiler magic. A dyn. array is 
> basically a pointer to the real dyn. array containing size information 
> and the data.

... and that's the cause.

At least I know and can decide between forgetting about dynamic arrays
or making an own implementation.

Thank you,
Marc





More information about the fpc-pascal mailing list