Files
xtool-mirror/Sources/XKit/Utilities/CHelpers.swift
2025-05-06 11:30:59 +05:30

29 lines
765 B
Swift

//
// CHelpers.swift
// XKit
//
// Created by Kabir Oberai on 13/10/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
import CXKit
package var stdoutSafe: UnsafeMutablePointer<FILE> {
get_stdout()
}
extension Data {
init?(deallocator: Deallocator = .free, acceptor: (inout Int) -> UnsafeMutableRawPointer?) {
var count = 0
guard let bytes = acceptor(&count) else { return nil }
self.init(bytesNoCopy: bytes, count: count, deallocator: deallocator)
}
init(deallocator: Deallocator = .free, acceptor: (inout Int) -> UnsafeMutableRawPointer) {
var count = 0
let bytes = acceptor(&count)
self.init(bytesNoCopy: bytes, count: count, deallocator: deallocator)
}
}