|
|
@@ -21,7 +21,7 @@ import Foundation // for String.Encoding
|
|
|
/// Representation of raw data that may be sent and received using gRPC
|
|
|
public class ByteBuffer {
|
|
|
/// Pointer to underlying C representation
|
|
|
- internal var underlyingByteBuffer: UnsafeMutableRawPointer!
|
|
|
+ internal var underlyingByteBuffer: UnsafeMutableRawPointer
|
|
|
|
|
|
/// Creates a ByteBuffer from an underlying C representation.
|
|
|
/// The ByteBuffer takes ownership of the passed-in representation.
|
|
|
@@ -35,9 +35,11 @@ public class ByteBuffer {
|
|
|
///
|
|
|
/// - Parameter data: the data to store in the buffer
|
|
|
public init(data: Data) {
|
|
|
+ var underlyingByteBuffer: UnsafeMutableRawPointer?
|
|
|
data.withUnsafeBytes { bytes in
|
|
|
underlyingByteBuffer = cgrpc_byte_buffer_create_by_copying_data(bytes, data.count)
|
|
|
}
|
|
|
+ self.underlyingByteBuffer = underlyingByteBuffer!
|
|
|
}
|
|
|
|
|
|
deinit {
|