|
|
@@ -48,7 +48,7 @@ func arrayOfBytes<T>(_ value: T, length: Int? = nil) -> [UInt8] {
|
|
|
|
|
|
let bytesPointer = UnsafeMutablePointer<UInt8>(valuePointer)
|
|
|
var bytes = [UInt8](repeating: 0, count: totalBytes)
|
|
|
- for j in 0..<min(sizeof(T), totalBytes) {
|
|
|
+ for j in 0..<min(sizeof(T.self), totalBytes) {
|
|
|
bytes[totalBytes - 1 - j] = (bytesPointer + j).pointee
|
|
|
}
|
|
|
|
|
|
@@ -60,7 +60,7 @@ func arrayOfBytes<T>(_ value: T, length: Int? = nil) -> [UInt8] {
|
|
|
|
|
|
extension Int {
|
|
|
/** Array of bytes with optional padding (little-endian) */
|
|
|
- func bytes(_ totalBytes: Int = sizeof(Int)) -> [UInt8] {
|
|
|
+ func bytes(_ totalBytes: Int = sizeof(Int.self)) -> [UInt8] {
|
|
|
return arrayOfBytes(self, length: totalBytes)
|
|
|
}
|
|
|
|
|
|
@@ -108,7 +108,7 @@ func toUInt32Array(_ slice: ArraySlice<UInt8>) -> Array<UInt32> {
|
|
|
var result = Array<UInt32>()
|
|
|
result.reserveCapacity(16)
|
|
|
|
|
|
- for idx in stride(from: slice.startIndex, to: slice.endIndex, by: sizeof(UInt32)) {
|
|
|
+ for idx in stride(from: slice.startIndex, to: slice.endIndex, by: sizeof(UInt32.self)) {
|
|
|
let d0 = UInt32(slice[idx.advanced(by: 3)]) << 24
|
|
|
let d1 = UInt32(slice[idx.advanced(by: 2)]) << 16
|
|
|
let d2 = UInt32(slice[idx.advanced(by: 1)]) << 8
|