Skip to content

Commit 3acea80

Browse files
authored
Merge pull request #1942 from compnerd/deprecated
Foundation: remove deprecated `bzero`
2 parents 12b5af5 + 580bd2a commit 3acea80

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

Foundation/NSData.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ open class NSMutableData : NSData {
971971

972972
/// Replaces with zeroes the contents of the data object in a given range.
973973
open func resetBytes(in range: NSRange) {
974-
bzero(mutableBytes.advanced(by: range.location), range.length)
974+
memset(mutableBytes.advanced(by: range.location), 0, range.length)
975975
}
976976

977977
/// Replaces the entire contents of the data object with the contents of another data object.

Foundation/NSSwiftRuntime.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ import CoreFoundation
2626
import WinSDK
2727
#endif
2828

29-
// shim required for bzero
30-
#if os(Android) || os(Windows)
31-
@_transparent func bzero(_ ptr: UnsafeMutableRawPointer, _ size: size_t) {
32-
memset(ptr, 0, size)
33-
}
34-
#endif
35-
3629
#if !_runtime(_ObjC)
3730
/// The Objective-C BOOL type.
3831
///
@@ -144,7 +137,7 @@ internal func _CFSwiftIsEqual(_ cf1: AnyObject, cf2: AnyObject) -> Bool {
144137
// Ivars in _NSCF* types must be zeroed via an unsafe accessor to avoid deinit of potentially unsafe memory to accces as an object/struct etc since it is stored via a foreign object graph
145138
internal func _CFZeroUnsafeIvars<T>(_ arg: inout T) {
146139
withUnsafeMutablePointer(to: &arg) { (ptr: UnsafeMutablePointer<T>) -> Void in
147-
bzero(UnsafeMutableRawPointer(ptr), MemoryLayout<T>.size)
140+
memset(UnsafeMutableRawPointer(ptr), 0, MemoryLayout<T>.size)
148141
}
149142
}
150143

0 commit comments

Comments
 (0)