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?

 

Regards,

 

Amit

 

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to