Skip to content

Commit

Permalink
Merge pull request #339 from microtherion/Inline_data
Browse files Browse the repository at this point in the history
Fix alignment crash in debug mode
  • Loading branch information
weichsel authored Dec 22, 2024
2 parents 8c370b8 + c1ce2fb commit 82168c5
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions Sources/ZIPFoundation/Data+Serialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ extension Data {
}

func scanValue<T>(start: Int) -> T {
let subdata = self.subdata(in: start..<start+MemoryLayout<T>.size)
#if swift(>=5.0)
return subdata.withUnsafeBytes { $0.load(as: T.self) }
#else
return subdata.withUnsafeBytes { $0.pointee }
#endif
return self.withUnsafeBytes {
$0.loadUnaligned(fromByteOffset: start, as: T.self)
}
}

static func readStruct<T>(from file: FILEPointer, at offset: UInt64)
Expand Down

0 comments on commit 82168c5

Please sign in to comment.