Skip to content

Commit

Permalink
use default overload for z_stream init
Browse files Browse the repository at this point in the history
  • Loading branch information
slice committed Nov 3, 2023
1 parent 45c2f80 commit 2d58a7c
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions Tempest/Gateway/Decompression.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ private func kibibytes(_ kb: Int) -> Int {
/// Wraps a long-lived zlib decompression stream to decompress Discord gateway
/// packets that are compressed with `zlib-stream`.
final class Decompression {
var stream: z_stream
var stream = z_stream()
var hasInitializedStream: Bool = false
static var log = Logger(subsystem: "zone.slice.Tempest", category: "decompression")

Expand Down Expand Up @@ -40,25 +40,6 @@ final class Decompression {
case zlib(ZlibCode, String?)
}

init() {
// The zlib manual says:
//
// > All other fields are set by the compression library and must not be
// > updated by the application.
//
// But whatever.
stream = .init(
next_in: nil, avail_in: 0, total_in: 0,
next_out: nil, avail_out: 0, total_out: 0,
msg: nil, state: nil,
// The following two fields being nil means that zlib will use malloc and
// free for memory management.
zalloc: nil,
zfree: nil,
opaque: nil, data_type: 0, adler: 0, reserved: 0
)
}

// Not using a buffer pointer here, since we'd like to point zlib into the
// middle of the output buffer (handy after resizing).
private func pointDestination(to buffer: UnsafeMutableRawPointer, available: Int) {
Expand Down

0 comments on commit 2d58a7c

Please sign in to comment.