|
@@ -339,7 +339,19 @@ function fpc_dynarray_copy(psrc : pointer;ti : pointer;
|
|
|
|
|
|
|
|
|
procedure DynArraySetLength(var a: Pointer; typeInfo: Pointer; dimCnt: SizeInt; lengthVec: PSizeInt);
|
|
|
+ var
|
|
|
+ preallocated : array[0..10] of PSizeInt;
|
|
|
+ i : SizeInt;
|
|
|
+ p : PSizeInt;
|
|
|
begin
|
|
|
- int_dynarray_setlength(a,typeInfo,dimCnt,lengthVec);
|
|
|
+ if dimCnt<=length(preallocated) then
|
|
|
+ p:=@preallocated
|
|
|
+ else
|
|
|
+ getmem(p,sizeof(SizeInt)*dimCnt);
|
|
|
+ for i:=0 to dimCnt-1 do
|
|
|
+ p[i]:=lengthVec[dimCnt-1-i];
|
|
|
+ int_dynarray_setlength(a,typeInfo,dimCnt,p);
|
|
|
+ if p<>@preallocated then
|
|
|
+ freemem(p);
|
|
|
end;
|
|
|
|