Re: [fpc-pascal] dynamic array as a part of dynamically allocated records behavior

2012-02-25 Thread Jonas Maebe
On 25 Feb 2012, at 13:23, leledumbo wrote: > The code results in AV in the last WriteLn. Is this correct (i.e. intended > behavior)? Yes. > If yes, what is the correct way to have the PR^.avl initialized > just like TR.avl and x? Use new(PR) instead of GetMem(SizeOf(TRuang)), or alternatively

Re: [fpc-pascal] dynamic array as a part of dynamically allocated records behavior

2012-02-25 Thread Mattias Gaertner
On Sat, 25 Feb 2012 04:23:24 -0800 (PST) leledumbo 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; >

[fpc-pascal] dynamic array as a part of dynamically allocated records behavior

2012-02-25 Thread leledumbo
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 := GetM