I have this feature in our Delphi 7 application that worked very well until I included FastMM4 v4.99 in the project. After turning on, FastMM4 raised the following error message: "FastMM detected an error during the FreeMem operation. The block footer was damaged." Execution stops at the FreeMem line.
function BinaryFieldToArrayOfWord( aBinaryField : TVarBytesField;
out aArrValues : TArrWord ) : Boolean;
var
p : Pointer;
begin
if not aBinaryField.IsBlob then
begin
GetMem( p, aBinaryField.DataSize );
try
if aBinaryField.GetData( p ) then
begin
// do something
end;
finally
FreeMem( p, aBinaryField.DataSize );
end;
end; // if
end;
At first I thought that there should be an error in the function, but it is almost the same as in the example with the TField.GetData example in the Delphi 7 help:
{ Retrieve the "raw" data from Field1 }
with Field1 do
begin
if not IsBlob { this does not work for BLOB fields }
begin
{ Allocate space }
GetMem(MyBuffer, DataSize);
try
if not GetData(MyBuffer) then
MessageDlg(DisplayName + ' is NULL', mtInformation, [mbOK], 0)
else
{ Do something with the data };
finally
{ Free the space }
FreeMem(MyBuffer, DataSize);
end;
end;
end;
, , . , , . , 2 :
GetMem( p, aBinaryField.DataSize + 2 );
FreeMem( p, aBinaryField.DataSize + 2 );
, , . . FastMM4 2 ?
. , , Delphi 7 TField.GetData. 2 . FastMM4 , ( FastMM4). TVarBytesField, .
, , .
: Delphis?
procedure TfrmMain_PBC_TH.btnDEBUGClick(Sender: TObject);
type
TArrBytes = array of Byte;
var
p : Pointer;
qryTest : TADOQuery;
begin
qryTest := TADOQuery.Create( Application );
try
qryTest.Connection := MainConn;
qryTest.SQL.Add('SELECT [BinData] FROM [TQM_BinaryData] WHERE [Id] = 168');
qryTest.Open;
GetMem( p, qryTest.FieldByName('BinData').DataSize );
try
qryTest.FieldByName('BinData').GetData( p );
finally
FreeMem( p );
end;
qryTest.Close;
finally
qryTest.Free;
end;
end;
:
@FillChar(???,???,???)
TDataSet.DataConvert($7D599770,$12F448,$7D51F7F0,True)
VarToBuffer
TCustomADODataSet.GetFieldData($7D599770,$7D51F7F0,True)
TField.GetData($7D51F7F0,True)
TfrmMain_PBC_TH.btnDEBUGClick($7FF7A380)
TControl.Click
TButton.Click