Skip to content

Commit

Permalink
fixed compilation with older Delphis
Browse files Browse the repository at this point in the history
  • Loading branch information
gabr42 committed Mar 12, 2018
1 parent b968342 commit 97a3991
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion OtlCollections.pas
Expand Up @@ -118,7 +118,7 @@ interface
{$IFDEF OTL_Generics}{$IFDEF OTL_HasArrayOfT}{$IFDEF OTL_ERTTI}
TypInfo,
RTTI,
System.Generics.Collections,
Generics.Collections,
{$ENDIF OTL_ERTTI}{$ENDIF OTL_HasArrayOfT}{$ENDIF OTL_Generics}
OtlCommon,
OtlContainers,
Expand Down
16 changes: 16 additions & 0 deletions src/GpLists.pas
Expand Up @@ -7814,7 +7814,11 @@ function TGpCache<K, V>.IsNil(element: integer): boolean; //inline
procedure TGpCache<K, V>.DestroyOwnedValues;
begin
while not IsNil(FHead) do begin
{$IF CompilerVersion < 25} // DisposeOf was implemented in XE4
PObject(@FKeys[FHead].Value)^.Free;
{$ELSE}
PObject(@FKeys[FHead].Value)^.DisposeOf;
{$IFEND}
FHead := FKeys[FHead].Next;
end;
end; { TGpCache<K, V>.DestroyOwnedValues }
Expand Down Expand Up @@ -7876,7 +7880,11 @@ function TGpCache<K, V>.Remove(const key: K): boolean;
FFreeList := element;
FCache.Remove(key);
if FOwnsValues then
{$IF CompilerVersion < 25} // DisposeOf was implemented in XE4
PObject(@pElement.Value)^.Free;
{$ELSE}
PObject(@pElement.Value)^.DisposeOf;
{$IFEND}
end;
end; { TGpCache<K, V>.Remove }

Expand All @@ -7890,7 +7898,11 @@ function TGpCache<K, V>.RemoveOldest: integer;
Unlink(FTail);
FCache.Remove(FKeys[Result].Key);
if FOwnsValues then
{$IF CompilerVersion < 25} // DisposeOf was implemented in XE4
PObject(@FKeys[Result].Value)^.Free;
{$ELSE}
PObject(@FKeys[Result].Value)^.DisposeOf;
{$IFEND}
end; { TGpCache<K, V>.RemoveOldest }

function TGpCache<K, V>.TryGetValue(const key: K; var value: V): boolean;
Expand Down Expand Up @@ -7939,7 +7951,11 @@ procedure TGpCache<K, V>.Update(const key: K; const value: V);
oldValue := pElement.Value;
pElement.Value := value;
if PObject(@oldValue)^ <> PObject(@value)^ then
{$IF CompilerVersion < 25} // DisposeOf was implemented in XE4
PObject(@oldValue)^.Free;
{$ELSE}
PObject(@oldValue)^.DisposeOf;
{$IFEND}
end;
Unlink(element);
InsertInFront(element);
Expand Down

0 comments on commit 97a3991

Please sign in to comment.