On Sat, 25 Feb 2012 04:23:24 -0800 (PST) leledumbo <leledumbo_c...@yahoo.co.id> wrote:
> Consider the following program: > > {$mode objfpc} > type > TJam = array of Integer; > > TRuang = record > nm_ruang: string; > avl: TJam; > end; > > PRuang = ^TRuang; > > var > x: array of integer; > TR: TRuang; > PR: PRuang; > begin > try > WriteLn(Length(x)); > WriteLn(Length(TR.avl)); > PR := GetMem(SizeOf(TRuang)); New(PR); > WriteLn(Length(PR^.avl)); > finally > FreeMem(PR); Dispose(PR); > end; > end. > > > The code results in AV in the last WriteLn. Is this correct (i.e. intended > behavior)? If yes, what is the correct way to have the PR^.avl initialized > just like TR.avl and x? New is GetMem+Initialization. Dispose is Finaliziation+FreeMem. Mattias _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal