Fix mem leak in GetServiceDefaultAddress and GetServiceDefaultFormatProperties

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1165 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
inoussa 2010-02-24 16:34:06 +00:00
parent b4f2e0ec15
commit 4251a64fec

View File

@ -124,16 +124,22 @@ var
typData : PTypeData; typData : PTypeData;
servcMdt : PService; servcMdt : PService;
propData : PPropertyData; propData : PPropertyData;
mmm : IModuleMetadataMngr;
begin begin
Result := ''; Result := '';
if Assigned(AServiceTyp) and (AServiceTyp^.Kind = tkInterface) then begin if Assigned(AServiceTyp) and (AServiceTyp^.Kind = tkInterface) then begin
typData := GetTypeData(AServiceTyp); typData := GetTypeData(AServiceTyp);
if Assigned(typData) then begin if Assigned(typData) then begin
servcMdt := GetModuleMetadataMngr().GetServiceMetadata(typData^.IntfUnit,AServiceTyp^.Name); mmm := GetModuleMetadataMngr();
if Assigned(AServiceTyp) then begin servcMdt := mmm.GetServiceMetadata(typData^.IntfUnit,AServiceTyp^.Name);
propData := Find(servcMdt^.Properties,sTRANSPORT + '_' + sADDRESS); if Assigned(servcMdt) then begin
if Assigned(propData) then try
Result := propData^.Data; propData := Find(servcMdt^.Properties,sTRANSPORT + '_' + sADDRESS);
if Assigned(propData) then
Result := propData^.Data;
finally
mmm.ClearServiceMetadata(servcMdt);
end;
end; end;
end; end;
end; end;
@ -145,25 +151,31 @@ var
servcMdt : PService; servcMdt : PService;
propData : PPropertyData; propData : PPropertyData;
strName : string; strName : string;
mmm : IModuleMetadataMngr;
begin begin
Result := ''; Result := '';
if Assigned(AServiceTyp) and (AServiceTyp^.Kind = tkInterface) then begin if Assigned(AServiceTyp) and (AServiceTyp^.Kind = tkInterface) then begin
typData := GetTypeData(AServiceTyp); typData := GetTypeData(AServiceTyp);
if Assigned(typData) then begin if Assigned(typData) then begin
servcMdt := GetModuleMetadataMngr().GetServiceMetadata(typData^.IntfUnit,AServiceTyp^.Name); mmm := GetModuleMetadataMngr();
if Assigned(AServiceTyp) then begin servcMdt := mmm.GetServiceMetadata(typData^.IntfUnit,AServiceTyp^.Name);
propData := servcMdt^.Properties; if Assigned(servcMdt) then begin
while Assigned(propData) do begin try
if ( AnsiPos(sFORMAT + '_',propData^.Name) = 1 ) then begin propData := servcMdt^.Properties;
strName := ExtractOptionName(propData^.Name); while Assigned(propData) do begin
if ( Length(strName) > 0 ) then begin if ( AnsiPos(sFORMAT + '_',propData^.Name) = 1 ) then begin
Result := Format('%s%s=%s;',[Result,strName,propData^.Data]); strName := ExtractOptionName(propData^.Name);
if ( Length(strName) > 0 ) then begin
Result := Format('%s%s=%s;',[Result,strName,propData^.Data]);
end;
end; end;
propData := propData^.Next;
end; end;
propData := propData^.Next; if not IsStrEmpty(Result) then begin
end; Delete(Result,Length(Result),1);
if not IsStrEmpty(Result) then begin end;
Delete(Result,Length(Result),1); finally
mmm.ClearServiceMetadata(servcMdt);
end; end;
end; end;
end; end;