Z
zxp_ping
Unregistered / Unconfirmed
GUEST, unregistred user!
我建立链表时,从一个库中读数据:
如上程序段,用MemProof总是指示
pReadInfo := new(PComputerInfo);
这一行,有8个字节的泄漏?这样将其加到链表中还用得着释放吗?释放了不就相应链表中也
释族掉了吗?
代码:
Function TComputerInfo.ReadFromDB:Boolean;
var
pReadInfo :PComputerInfo;
sTemp, sUseTime, sTag, sNight :String;
begin
result := false;
try
with dmServer.qrytemp do
begin
Close;
sql.Clear;
sql.Add('Select * from tbComputerInfo');
Prepare;
Open;
First;
while not eof do
begin
pReadInfo := new(PComputerInfo);
pReadInfo^ := TMyComputerINfo.Create;
pReadInfo.iImageIndex := FieldByName('ImageIndex').AsInteger;
pReadInfo.sComputerName := FieldByName('ComputerName').AsString;
pReadInfo.dBeginTime := FieldByName('BeginTime').AsDateTime;
pReadInfo.sCardNo := FieldByName('CardNo').AsString;
pReadInfo.sCID := FieldByName('CID').AsString;
pReadInfo.sGroupName := FieldByName('UseType').AsString;
pReadInfo.pNext := nil;
AddItem(pReadInfo);
pReadInfo := nil;
next;
end;
end;
except
result := false;
exit;
end;
result := true;
end;
如上程序段,用MemProof总是指示
pReadInfo := new(PComputerInfo);
这一行,有8个字节的泄漏?这样将其加到链表中还用得着释放吗?释放了不就相应链表中也
释族掉了吗?