From a28882ae002cea178dd9fd8de6f729b7fa007f19 Mon Sep 17 00:00:00 2001 From: Remy Lebeau Date: Mon, 12 Jul 2021 11:01:44 -0700 Subject: [PATCH] Undefining HAS_System_RegisterExpectedMemoryLeak for non-Windows platforms in Delphi 2006+. Tweaking the conditions that define REGISTER_EXPECTED_MEMORY_LEAK. --- Lib/Core/IdCompilerDefines.inc | 20 ++++++++------------ Lib/FCL/IdCompilerDefines.inc | 20 ++++++++------------ Lib/Protocols/IdCompilerDefines.inc | 20 ++++++++------------ Lib/SuperCore/IdCompilerDefines.inc | 20 ++++++++------------ Lib/System/IdCompilerDefines.inc | 20 ++++++++------------ Lib/System/IdGlobal.pas | 8 ++------ 6 files changed, 42 insertions(+), 66 deletions(-) diff --git a/Lib/Core/IdCompilerDefines.inc b/Lib/Core/IdCompilerDefines.inc index 3d2780205..ce1618575 100644 --- a/Lib/Core/IdCompilerDefines.inc +++ b/Lib/Core/IdCompilerDefines.inc @@ -43,6 +43,7 @@ // as specified further below. This works in conjunction with the // FREE_ON_FINAL define above. {$UNDEF REGISTER_EXPECTED_MEMORY_LEAK} +{$UNDEF HAS_System_RegisterExpectedMemoryLeak} // FastMM is natively available in BDS 2006 and higher. $DEFINE the // following if FastMM has been installed manually in earlier versions @@ -1140,11 +1141,9 @@ {$IFDEF VCL_2006_OR_ABOVE} {$DEFINE USE_INLINE} {$DEFINE HAS_2PARAM_FileAge} - {$DEFINE HAS_System_RegisterExpectedMemoryLeak} - {$IFNDEF FREE_ON_FINAL} - {$IFNDEF DOTNET} - {$DEFINE REGISTER_EXPECTED_MEMORY_LEAK} - {$ENDIF} + {$IFDEF WINDOWS} + // System.RegisterExpectedMemoryLeak() is only available on Windows at this time + {$DEFINE HAS_System_RegisterExpectedMemoryLeak} {$ENDIF} // In C++Builder 2006 and 2007, UInt64 is emitted as signed __int64 in HPP // files instead of as unsigned __int64. This causes conflicts in overloaded @@ -1890,7 +1889,10 @@ word to an 8 bit byte and an 8 bit byte field named sa_len was added. {$ENDIF} {$IFNDEF FREE_ON_FINAL} - {$IFNDEF REGISTER_EXPECTED_MEMORY_LEAK} + {$IFNDEF DOTNET} + {$IFDEF HAS_System_RegisterExpectedMemoryLeak} + {$DEFINE REGISTER_EXPECTED_MEMORY_LEAK} + {$ENDIF} {$IFDEF USE_FASTMM4} {$DEFINE REGISTER_EXPECTED_MEMORY_LEAK} {$ENDIF} @@ -1903,12 +1905,6 @@ word to an 8 bit byte and an 8 bit byte field named sa_len was added. {$ENDIF} {$ENDIF} -{$IFDEF REGISTER_EXPECTED_MEMORY_LEAK} - {$IFDEF DOTNET} - {$UNDEF REGISTER_EXPECTED_MEMORY_LEAK} - {$ENDIF} -{$ENDIF} - { We must determine what the SocketType parameter is for the Socket function. In DotNET, it's SocketType. In Kylix and the libc.pas Kylix-compatibility diff --git a/Lib/FCL/IdCompilerDefines.inc b/Lib/FCL/IdCompilerDefines.inc index 3d2780205..ce1618575 100644 --- a/Lib/FCL/IdCompilerDefines.inc +++ b/Lib/FCL/IdCompilerDefines.inc @@ -43,6 +43,7 @@ // as specified further below. This works in conjunction with the // FREE_ON_FINAL define above. {$UNDEF REGISTER_EXPECTED_MEMORY_LEAK} +{$UNDEF HAS_System_RegisterExpectedMemoryLeak} // FastMM is natively available in BDS 2006 and higher. $DEFINE the // following if FastMM has been installed manually in earlier versions @@ -1140,11 +1141,9 @@ {$IFDEF VCL_2006_OR_ABOVE} {$DEFINE USE_INLINE} {$DEFINE HAS_2PARAM_FileAge} - {$DEFINE HAS_System_RegisterExpectedMemoryLeak} - {$IFNDEF FREE_ON_FINAL} - {$IFNDEF DOTNET} - {$DEFINE REGISTER_EXPECTED_MEMORY_LEAK} - {$ENDIF} + {$IFDEF WINDOWS} + // System.RegisterExpectedMemoryLeak() is only available on Windows at this time + {$DEFINE HAS_System_RegisterExpectedMemoryLeak} {$ENDIF} // In C++Builder 2006 and 2007, UInt64 is emitted as signed __int64 in HPP // files instead of as unsigned __int64. This causes conflicts in overloaded @@ -1890,7 +1889,10 @@ word to an 8 bit byte and an 8 bit byte field named sa_len was added. {$ENDIF} {$IFNDEF FREE_ON_FINAL} - {$IFNDEF REGISTER_EXPECTED_MEMORY_LEAK} + {$IFNDEF DOTNET} + {$IFDEF HAS_System_RegisterExpectedMemoryLeak} + {$DEFINE REGISTER_EXPECTED_MEMORY_LEAK} + {$ENDIF} {$IFDEF USE_FASTMM4} {$DEFINE REGISTER_EXPECTED_MEMORY_LEAK} {$ENDIF} @@ -1903,12 +1905,6 @@ word to an 8 bit byte and an 8 bit byte field named sa_len was added. {$ENDIF} {$ENDIF} -{$IFDEF REGISTER_EXPECTED_MEMORY_LEAK} - {$IFDEF DOTNET} - {$UNDEF REGISTER_EXPECTED_MEMORY_LEAK} - {$ENDIF} -{$ENDIF} - { We must determine what the SocketType parameter is for the Socket function. In DotNET, it's SocketType. In Kylix and the libc.pas Kylix-compatibility diff --git a/Lib/Protocols/IdCompilerDefines.inc b/Lib/Protocols/IdCompilerDefines.inc index 3d2780205..ce1618575 100644 --- a/Lib/Protocols/IdCompilerDefines.inc +++ b/Lib/Protocols/IdCompilerDefines.inc @@ -43,6 +43,7 @@ // as specified further below. This works in conjunction with the // FREE_ON_FINAL define above. {$UNDEF REGISTER_EXPECTED_MEMORY_LEAK} +{$UNDEF HAS_System_RegisterExpectedMemoryLeak} // FastMM is natively available in BDS 2006 and higher. $DEFINE the // following if FastMM has been installed manually in earlier versions @@ -1140,11 +1141,9 @@ {$IFDEF VCL_2006_OR_ABOVE} {$DEFINE USE_INLINE} {$DEFINE HAS_2PARAM_FileAge} - {$DEFINE HAS_System_RegisterExpectedMemoryLeak} - {$IFNDEF FREE_ON_FINAL} - {$IFNDEF DOTNET} - {$DEFINE REGISTER_EXPECTED_MEMORY_LEAK} - {$ENDIF} + {$IFDEF WINDOWS} + // System.RegisterExpectedMemoryLeak() is only available on Windows at this time + {$DEFINE HAS_System_RegisterExpectedMemoryLeak} {$ENDIF} // In C++Builder 2006 and 2007, UInt64 is emitted as signed __int64 in HPP // files instead of as unsigned __int64. This causes conflicts in overloaded @@ -1890,7 +1889,10 @@ word to an 8 bit byte and an 8 bit byte field named sa_len was added. {$ENDIF} {$IFNDEF FREE_ON_FINAL} - {$IFNDEF REGISTER_EXPECTED_MEMORY_LEAK} + {$IFNDEF DOTNET} + {$IFDEF HAS_System_RegisterExpectedMemoryLeak} + {$DEFINE REGISTER_EXPECTED_MEMORY_LEAK} + {$ENDIF} {$IFDEF USE_FASTMM4} {$DEFINE REGISTER_EXPECTED_MEMORY_LEAK} {$ENDIF} @@ -1903,12 +1905,6 @@ word to an 8 bit byte and an 8 bit byte field named sa_len was added. {$ENDIF} {$ENDIF} -{$IFDEF REGISTER_EXPECTED_MEMORY_LEAK} - {$IFDEF DOTNET} - {$UNDEF REGISTER_EXPECTED_MEMORY_LEAK} - {$ENDIF} -{$ENDIF} - { We must determine what the SocketType parameter is for the Socket function. In DotNET, it's SocketType. In Kylix and the libc.pas Kylix-compatibility diff --git a/Lib/SuperCore/IdCompilerDefines.inc b/Lib/SuperCore/IdCompilerDefines.inc index 3d2780205..ce1618575 100644 --- a/Lib/SuperCore/IdCompilerDefines.inc +++ b/Lib/SuperCore/IdCompilerDefines.inc @@ -43,6 +43,7 @@ // as specified further below. This works in conjunction with the // FREE_ON_FINAL define above. {$UNDEF REGISTER_EXPECTED_MEMORY_LEAK} +{$UNDEF HAS_System_RegisterExpectedMemoryLeak} // FastMM is natively available in BDS 2006 and higher. $DEFINE the // following if FastMM has been installed manually in earlier versions @@ -1140,11 +1141,9 @@ {$IFDEF VCL_2006_OR_ABOVE} {$DEFINE USE_INLINE} {$DEFINE HAS_2PARAM_FileAge} - {$DEFINE HAS_System_RegisterExpectedMemoryLeak} - {$IFNDEF FREE_ON_FINAL} - {$IFNDEF DOTNET} - {$DEFINE REGISTER_EXPECTED_MEMORY_LEAK} - {$ENDIF} + {$IFDEF WINDOWS} + // System.RegisterExpectedMemoryLeak() is only available on Windows at this time + {$DEFINE HAS_System_RegisterExpectedMemoryLeak} {$ENDIF} // In C++Builder 2006 and 2007, UInt64 is emitted as signed __int64 in HPP // files instead of as unsigned __int64. This causes conflicts in overloaded @@ -1890,7 +1889,10 @@ word to an 8 bit byte and an 8 bit byte field named sa_len was added. {$ENDIF} {$IFNDEF FREE_ON_FINAL} - {$IFNDEF REGISTER_EXPECTED_MEMORY_LEAK} + {$IFNDEF DOTNET} + {$IFDEF HAS_System_RegisterExpectedMemoryLeak} + {$DEFINE REGISTER_EXPECTED_MEMORY_LEAK} + {$ENDIF} {$IFDEF USE_FASTMM4} {$DEFINE REGISTER_EXPECTED_MEMORY_LEAK} {$ENDIF} @@ -1903,12 +1905,6 @@ word to an 8 bit byte and an 8 bit byte field named sa_len was added. {$ENDIF} {$ENDIF} -{$IFDEF REGISTER_EXPECTED_MEMORY_LEAK} - {$IFDEF DOTNET} - {$UNDEF REGISTER_EXPECTED_MEMORY_LEAK} - {$ENDIF} -{$ENDIF} - { We must determine what the SocketType parameter is for the Socket function. In DotNET, it's SocketType. In Kylix and the libc.pas Kylix-compatibility diff --git a/Lib/System/IdCompilerDefines.inc b/Lib/System/IdCompilerDefines.inc index 3d2780205..ce1618575 100644 --- a/Lib/System/IdCompilerDefines.inc +++ b/Lib/System/IdCompilerDefines.inc @@ -43,6 +43,7 @@ // as specified further below. This works in conjunction with the // FREE_ON_FINAL define above. {$UNDEF REGISTER_EXPECTED_MEMORY_LEAK} +{$UNDEF HAS_System_RegisterExpectedMemoryLeak} // FastMM is natively available in BDS 2006 and higher. $DEFINE the // following if FastMM has been installed manually in earlier versions @@ -1140,11 +1141,9 @@ {$IFDEF VCL_2006_OR_ABOVE} {$DEFINE USE_INLINE} {$DEFINE HAS_2PARAM_FileAge} - {$DEFINE HAS_System_RegisterExpectedMemoryLeak} - {$IFNDEF FREE_ON_FINAL} - {$IFNDEF DOTNET} - {$DEFINE REGISTER_EXPECTED_MEMORY_LEAK} - {$ENDIF} + {$IFDEF WINDOWS} + // System.RegisterExpectedMemoryLeak() is only available on Windows at this time + {$DEFINE HAS_System_RegisterExpectedMemoryLeak} {$ENDIF} // In C++Builder 2006 and 2007, UInt64 is emitted as signed __int64 in HPP // files instead of as unsigned __int64. This causes conflicts in overloaded @@ -1890,7 +1889,10 @@ word to an 8 bit byte and an 8 bit byte field named sa_len was added. {$ENDIF} {$IFNDEF FREE_ON_FINAL} - {$IFNDEF REGISTER_EXPECTED_MEMORY_LEAK} + {$IFNDEF DOTNET} + {$IFDEF HAS_System_RegisterExpectedMemoryLeak} + {$DEFINE REGISTER_EXPECTED_MEMORY_LEAK} + {$ENDIF} {$IFDEF USE_FASTMM4} {$DEFINE REGISTER_EXPECTED_MEMORY_LEAK} {$ENDIF} @@ -1903,12 +1905,6 @@ word to an 8 bit byte and an 8 bit byte field named sa_len was added. {$ENDIF} {$ENDIF} -{$IFDEF REGISTER_EXPECTED_MEMORY_LEAK} - {$IFDEF DOTNET} - {$UNDEF REGISTER_EXPECTED_MEMORY_LEAK} - {$ENDIF} -{$ENDIF} - { We must determine what the SocketType parameter is for the Socket function. In DotNET, it's SocketType. In Kylix and the libc.pas Kylix-compatibility diff --git a/Lib/System/IdGlobal.pas b/Lib/System/IdGlobal.pas index 9d1bec56e..5d876efec 100644 --- a/Lib/System/IdGlobal.pas +++ b/Lib/System/IdGlobal.pas @@ -1848,10 +1848,8 @@ function IndyMax(const AValueOne, AValueTwo: Int32): Int32; overload; function IndyMax(const AValueOne, AValueTwo: UInt16): UInt16; overload; function IPv4MakeUInt32InRange(const AInt: Int64; const A256Power: Integer): UInt32; function IPv4MakeLongWordInRange(const AInt: Int64; const A256Power: Integer): UInt32; {$IFDEF HAS_DEPRECATED}deprecated{$IFDEF HAS_DEPRECATED_MSG} 'Use IPv4MakeUInt32InRange()'{$ENDIF};{$ENDIF} -{$IFNDEF DOTNET} - {$IFDEF REGISTER_EXPECTED_MEMORY_LEAK} +{$IFDEF REGISTER_EXPECTED_MEMORY_LEAK} function IndyRegisterExpectedMemoryLeak(AAddress: Pointer): Boolean; - {$ENDIF} {$ENDIF} function LoadLibFunction(const ALibHandle: TIdLibHandle; const AProcName: TIdLibFuncName): Pointer; {$IFDEF UNIX} @@ -9746,8 +9744,7 @@ function ReadLnFromStream(AStream: TStream; var VLine: String; AMaxLineLength: I Result := True; end; -{$IFNDEF DOTNET} - {$IFDEF REGISTER_EXPECTED_MEMORY_LEAK} +{$IFDEF REGISTER_EXPECTED_MEMORY_LEAK} function IndyRegisterExpectedMemoryLeak(AAddress: Pointer): Boolean; {$IFDEF USE_INLINE}inline;{$ENDIF} begin @@ -9801,7 +9798,6 @@ function IndyRegisterExpectedMemoryLeak(AAddress: Pointer): Boolean; {$ENDIF} {$ENDIF} end; - {$ENDIF} {$ENDIF} function IndyAddPair(AStrings: TStrings; const AName, AValue: String): TStrings;