Am 18.10.2011 21:59, schrieb Jonas Maebe:

On 18 Oct 2011, at 21:55, Sven Barth wrote:


type
  TGenArray<T>  = array of T; // this should work in trunk already

function Concat<T>(Arr1, Arr2: TGenArray<T>): TGenArray<T>;
begin
  SetLength(Result, Length(aArray1) + Length(aArray2));
  if Length(aArray1)>  0 then
    Move(aArray1[0], Result[0], Length(aArray1) * SizeOf(T));
  if Length(aArray2)>  0 then
    Move(aArray2[0], Result[Length(aArray1)], Length(aArray2) * SizeOf(T));
end;

This implementation will result in crashes if T is a reference-counted type.

Right... I tend to forget about these... what would the correct way to copy an array of ref counted types? E.g. an "array of string"?

Regards,
Sven

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

Reply via email to