You are not logged in.
When Member data is managed externally,like
var
SynMustacheCache: TSynMustacheCache = nil;
SynMustacheCache's data update,will Trigger exception when memory release.
so:
TRawUtf8List.AddObject Suggest adding aReplaceAndFreeOldObject.
function AddObject(const aText: RawUtf8; aObject: TObject;
aRaiseExceptionIfExisting: boolean = false;
aFreeAndReturnExistingObject: PPointer = nil;
aReplaceExistingObject: boolean = false;
aReplaceAndFreeOldObject: boolean = true): PtrInt;
add aReplaceAndFreeOldObject: boolean
and
update here
if aReplaceExistingObject then
begin
if Obj = nil then
raise ESynException.CreateUtf8
('%.AddOrReplaceObject with no object at [%]', [self, aText]);
if aReplaceAndFreeOldObject then //add here
FreeAndNil(fObjects[result]);
fObjects[result] := aObject;
end
else
result := -1;
exit;
when we need update ,can set aReplaceAndFreeOldObject:=false;
Last edited by suoke (2023-02-26 07:56:07)
Offline