[fpc-pascal] dynamic array and new/dispose
Jonas Maebe
jonas.maebe at elis.ugent.be
Wed Feb 2 10:16:32 CET 2011
On 02 Feb 2011, at 09:20, Amit Bueno wrote:
> // 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?
>
Are you compiling in Delphi mode? Please *always* post compilable
source code that demonstrates the problem when asking for help, not
uncompilable snippets. Don't make people guess about what you might
have written or about how you are compiling it.
Jonas
More information about the fpc-pascal
mailing list