On 04 Feb 2011, at 16:25, Bo Berglund wrote:

> OK, what will happen if I have a declaration like this:
> function TSSCommBuf.Read(var Data: TByteArr): boolean; 
> as opposed to
> function TSSCommBuf.Read(Data: TByteArr): boolean;
> 
> Will they be equivalent or will there be an "extra layer" of pointer??

They are different. And it's not just "an extra layer of pointer", both 
declarations allow you to do different things. In the second case, you make a 
copy of the dynamic array and hence its reference count is increased. In the 
first case, you pass in the original dynamic array in, and hence
a) no increase in reference count
b) if you do e.g. "data:=nil", then the variable that was passed in will set to 
nil and the reference count of the dynamic array will decrease (and if it 
becomes zeroed, it will be freed)


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

Reply via email to