From 2c5dd8804bb7df7a03d68b53ef3241c8f2cbd529 Mon Sep 17 00:00:00 2001 From: Peter Date: Fri, 4 Nov 2016 12:59:00 +0300 Subject: [PATCH] no message --- Postbox/Coding.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Postbox/Coding.swift b/Postbox/Coding.swift index 67eec67e5f..78dc390e3c 100644 --- a/Postbox/Coding.swift +++ b/Postbox/Coding.swift @@ -91,6 +91,14 @@ public class MemoryBuffer: Equatable, CustomStringConvertible { return hexString as String } + + public func makeData() -> Data { + if self.length == 0 { + return Data() + } else { + return Data(bytes: self.memory, count: self.length) + } + } } public func ==(lhs: MemoryBuffer, rhs: MemoryBuffer) -> Bool { @@ -116,7 +124,7 @@ public final class WriteBuffer: MemoryBuffer { return ReadBuffer(memory: self.memory, length: self.offset, freeWhenDone: false) } - public func makeData() -> Data { + override public func makeData() -> Data { return Data(bytes: self.memory.assumingMemoryBound(to: UInt8.self), count: self.offset) }