Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.
Become a Premium Member and unlock a new, free course in leading technologies each month.
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
procedure TBits.SetSize(Value: Cardinal);
var
NewMem: Pointer;
NewMemSize: Cardinal;
OldMemSize: Cardinal;
function Min(X, Y: Integer): Integer;
begin
Result := X;
if X > Y then Result := Y;
end;
begin
if Value <> Size then
begin
if Value < 0 then Error;
NewMemSize := ((Int64(Value) + BitsPerInt - 1) div BitsPerInt) * SizeOf(Cardinal);
OldMemSize := ((Int64(Size) + BitsPerInt - 1) div BitsPerInt) * SizeOf(Cardinal);
if NewMemSize <> OldMemSize then
begin
NewMem := nil;
if NewMemSize <> 0 then
begin
GetMem(NewMem, NewMemSize);
FillChar(NewMem^, NewMemSize, 0);
end;
if OldMemSize <> 0 then
begin
if NewMem <> nil then
Move(FBits^, NewMem^, Min(OldMemSize, NewMemSize));
FreeMem(FBits, OldMemSize);
end;
FBits := NewMem;
end;
FSize := Value;
end;
end;
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.