Skip to content

Commit 03e2846

Browse files
authored
Merge pull request #1337 from ianpartridge/exclusive-access
2 parents 13a61a6 + 5418b99 commit 03e2846

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Foundation/NSCalendar.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,9 @@ open class NSCalendar : NSObject, NSCopying, NSSecureCoding {
583583
var at: CFAbsoluteTime = date.timeIntervalSinceReferenceDate
584584

585585
let res: Bool = withUnsafeMutablePointer(to: &at) { t in
586+
let count = Int32(vector.count)
586587
return vector.withUnsafeMutableBufferPointer { (vectorBuffer: inout UnsafeMutableBufferPointer<Int32>) in
587-
return _CFCalendarAddComponentsV(_cfObject, t, CFOptionFlags(opts.rawValue), compDesc, vectorBuffer.baseAddress!, Int32(vector.count))
588+
return _CFCalendarAddComponentsV(_cfObject, t, CFOptionFlags(opts.rawValue), compDesc, vectorBuffer.baseAddress!, count)
588589
}
589590
}
590591

@@ -603,8 +604,9 @@ open class NSCalendar : NSObject, NSCopying, NSSecureCoding {
603604
return intArrayBuffer.baseAddress!.advanced(by: idx)
604605
}
605606

607+
let count = Int32(vector.count)
606608
return vector.withUnsafeMutableBufferPointer { (vecBuffer: inout UnsafeMutableBufferPointer<UnsafeMutablePointer<Int32>>) in
607-
return _CFCalendarGetComponentDifferenceV(_cfObject, startingDate.timeIntervalSinceReferenceDate, resultDate.timeIntervalSinceReferenceDate, CFOptionFlags(opts.rawValue), compDesc, vecBuffer.baseAddress!, Int32(vector.count))
609+
return _CFCalendarGetComponentDifferenceV(_cfObject, startingDate.timeIntervalSinceReferenceDate, resultDate.timeIntervalSinceReferenceDate, CFOptionFlags(opts.rawValue), compDesc, vecBuffer.baseAddress!, count)
608610
}
609611
}
610612
if res {

TestFoundation/TestNSData.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -930,11 +930,11 @@ extension TestNSData {
930930
// Mutate it
931931
bytes.pointee = 0x67
932932
XCTAssertEqual(bytes.pointee, 0x67, "First byte should be 0x67")
933-
XCTAssertEqual(mutatingHello[0], 0x67, "First byte accessed via other method should still be 0x67")
934-
935-
// Verify that the first data is still correct
936-
XCTAssertEqual(hello[0], 0x68, "The first byte should still be 0x68")
937933
}
934+
XCTAssertEqual(mutatingHello[0], 0x67, "First byte accessed via other method should still be 0x67")
935+
936+
// Verify that the first data is still correct
937+
XCTAssertEqual(hello[0], 0x68, "The first byte should still be 0x68")
938938
}
939939

940940

0 commit comments

Comments
 (0)