mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 20:09:25 +02:00
* Call management operator (Initialize) for records when SetLength for dynamic arrays is used.
git-svn-id: trunk@35450 -
This commit is contained in:
parent
5a7d4eb25f
commit
0cff9fe83c
@ -27,6 +27,7 @@
|
||||
Procedure int_Finalize (Data,TypeInfo: Pointer); [external name 'FPC_FINALIZE'];
|
||||
Procedure int_Addref (Data,TypeInfo : Pointer); [external name 'FPC_ADDREF'];
|
||||
Procedure int_Initialize (Data,TypeInfo: Pointer); [external name 'FPC_INITIALIZE'];
|
||||
procedure int_InitializeArray(data,typeinfo : pointer;count : SizeInt); [external name 'FPC_INITIALIZE_ARRAY'];
|
||||
procedure int_FinalizeArray(data,typeinfo : pointer;count : SizeInt); [external name 'FPC_FINALIZE_ARRAY'];
|
||||
|
||||
{$if defined(FPC_HAS_FEATURE_RTTI) and not defined(cpujvm)}
|
||||
|
@ -193,6 +193,11 @@ procedure fpc_dynarray_setlength(var p : pointer;pti : pointer;
|
||||
exit;
|
||||
getmem(newp,size);
|
||||
fillchar(newp^,size,0);
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{ call int_InitializeArray for management operators }
|
||||
if assigned(eletypemngd) and (PByte(eletype)^ in [tkRecord, tkObject]) then
|
||||
int_InitializeArray(pointer(newp)+sizeof(tdynarray), eletype, dims[0]);
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
updatep := true;
|
||||
end
|
||||
else
|
||||
@ -265,6 +270,12 @@ procedure fpc_dynarray_setlength(var p : pointer;pti : pointer;
|
||||
reallocmem(realp,size);
|
||||
fillchar((pointer(realp)+sizeof(tdynarray)+elesize*(realp^.high+1))^,
|
||||
(dims[0]-realp^.high-1)*elesize,0);
|
||||
{$ifdef FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
{ call int_InitializeArray for management operators }
|
||||
if assigned(eletypemngd) and (PByte(eletype)^ in [tkRecord, tkObject]) then
|
||||
int_InitializeArray(pointer(realp)+sizeof(tdynarray)+elesize*(realp^.high+1),
|
||||
eletype, dims[0]-realp^.high-1);
|
||||
{$endif FPC_HAS_MANAGEMENT_OPERATORS}
|
||||
end;
|
||||
newp := realp;
|
||||
updatep := true;
|
||||
|
Loading…
Reference in New Issue
Block a user