[fpc-pascal] dynamic array and new/dispose

ik idokan at gmail.com
Wed Feb 2 09:30:37 CET 2011


On Wed, Feb 2, 2011 at 10:20, Amit Bueno <amitbueno at gmail.com> wrote:

> I am writing an application on iMac, and having problem dynamically
> creating objects and reading them into an array:
>
>
>
> // I got the following object:
>
>      PChunk = ^Chunk;
>
>      Chunk = Object
>
>               SubChunks: array of PChunk;
>
>               Data: Pointer; .
>
>               Function NewSubchunk: integer;
>
>               Procedure Read(var Fl: TStream);
>
>               Constructor Create;
>
>               Destructor Destroy;
>
>              end;
>
>
>
> // creating and reading more data
>
> SubChunks[NewSubChunk]^.read(Fl);
>
>
>
> // NewSubChunk function
>
> Function Chunk.NewSubchunk: integer;
>
> begin
>
>   setlength(SubChunks, High(SubChunks)+2);
>
>   New(subchunks[High(SubChunks)], create);
>
>   SubChunks[High(SubChunks)]^.Data := Self.Data;
>
>   Result := High(SubChunks);
>
> end;
>
>
>
> // ---------
>
> The procedure fails when running the:
>
> SubChunks[NewSubChunk]^.read(Fl);
>
>
>
> All the procedure works fine on Delphi, but on fpc under iMac it fails.
>
> Why?
>

What is the error message you are having ?


>
>
> Regards,
>
>
>
> *Amit*
>
>
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>


Ido
LINESIP - Opening the source for communication
http://www.linesip.com
http://www.linesip.co.il
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20110202/351b4cd8/attachment.html>


More information about the fpc-pascal mailing list