Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit ffdea34

Browse files
committed
Remove dead code in ZLibNative
1 parent cc5d4cd commit ffdea34

File tree

1 file changed

+3
-55
lines changed

1 file changed

+3
-55
lines changed

src/System.IO.Compression/src/System/IO/Compression/ZLibNative.cs

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright (c) Microsoft. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4+
using System.Diagnostics;
45
using System.Diagnostics.Contracts;
56
using System.Runtime.InteropServices;
67
using System.Security;
7-
using System.Text;
88

99
namespace System.IO.Compression
1010
{
@@ -221,7 +221,6 @@ public enum State { NotInitialized, InitializedForDeflate, InitializedForInflate
221221

222222

223223
public ZLibStreamHandle()
224-
225224
: base(new IntPtr(-1), true)
226225
{
227226
_zStream = new ZStream();
@@ -236,7 +235,7 @@ public ZLibStreamHandle()
236235
public override bool IsInvalid
237236
{
238237
[SecurityCritical]
239-
get { return DangerousGetHandle() == new IntPtr(-1); }
238+
get { return handle == new IntPtr(-1); }
240239
}
241240

242241
public State InitializationState
@@ -250,9 +249,6 @@ public State InitializationState
250249
[SecurityCritical]
251250
protected override bool ReleaseHandle()
252251
{
253-
// We are in a finalizer thread at the end of the App and the finalization of the dynamically loaded ZLib happend
254-
// to be scheduled first. In such case we have no hope of properly freeing zStream. If the process is dying - we
255-
// do not care. In other cases somethign went badly wrong anyway:
256252
switch (InitializationState)
257253
{
258254
case State.NotInitialized: return true;
@@ -412,33 +408,11 @@ public ErrorCode InflateEnd()
412408
public string GetErrorMessage()
413409
{
414410
// This can work even after XxflateEnd().
415-
416-
if (ZNullPtr.Equals(_zStream.msg))
417-
return String.Empty;
418-
419-
unsafe
420-
{
421-
StringBuilder sb = new StringBuilder();
422-
SByte* pMessage = (SByte*)_zStream.msg;
423-
char c;
424-
do
425-
{
426-
c = (char)*pMessage;
427-
pMessage++;
428-
sb.Append(c);
429-
} while ((sbyte)c != 0);
430-
431-
return sb.ToString();
432-
}
411+
return _zStream.msg != ZNullPtr ? Marshal.PtrToStringAnsi(_zStream.msg) : string.Empty;
433412
}
434413

435414
#endregion // Expose ZLib functions for use by user / Fx code (add more as required)
436415

437-
[SecurityCritical]
438-
internal static Int32 ZLibCompileFlags()
439-
{
440-
return Interop.zlib.zlibCompileFlags();
441-
}
442416
} // class ZLibStreamHandle
443417

444418
#endregion // ZLib Stream Handle type
@@ -447,15 +421,6 @@ internal static Int32 ZLibCompileFlags()
447421
#region public factory methods for ZLibStreamHandle
448422

449423

450-
[SecurityCritical]
451-
public static ErrorCode CreateZLibStreamForDeflate(out ZLibStreamHandle zLibStreamHandle)
452-
{
453-
return CreateZLibStreamForDeflate(out zLibStreamHandle,
454-
CompressionLevel.DefaultCompression, Deflate_DefaultWindowBits,
455-
Deflate_DefaultMemLevel, CompressionStrategy.DefaultStrategy);
456-
}
457-
458-
459424
[SecurityCritical]
460425
public static ErrorCode CreateZLibStreamForDeflate(out ZLibStreamHandle zLibStreamHandle,
461426
CompressionLevel level, int windowBits, int memLevel, CompressionStrategy strategy)
@@ -465,13 +430,6 @@ public static ErrorCode CreateZLibStreamForDeflate(out ZLibStreamHandle zLibStre
465430
}
466431

467432

468-
[SecurityCritical]
469-
public static ErrorCode CreateZLibStreamForInflate(out ZLibStreamHandle zLibStreamHandle)
470-
{
471-
return CreateZLibStreamForInflate(out zLibStreamHandle, Deflate_DefaultWindowBits);
472-
}
473-
474-
475433
[SecurityCritical]
476434
public static ErrorCode CreateZLibStreamForInflate(out ZLibStreamHandle zLibStreamHandle, int windowBits)
477435
{
@@ -481,15 +439,5 @@ public static ErrorCode CreateZLibStreamForInflate(out ZLibStreamHandle zLibStre
481439

482440
#endregion // public factory methods for ZLibStreamHandle
483441

484-
485-
#region public utility APIs
486-
487-
[SecurityCritical]
488-
public static Int32 ZLibCompileFlags()
489-
{
490-
return ZLibStreamHandle.ZLibCompileFlags();
491-
}
492-
#endregion // public utility APIs
493-
494442
} // internal class ZLibNative
495443
} // namespace System.IO.Compression

0 commit comments

Comments
 (0)