From 71f203a1a0dc249a5dd241603192495badaca212 Mon Sep 17 00:00:00 2001 From: Charles Stanhope Date: Tue, 23 Nov 2010 05:47:32 +0800 Subject: [PATCH 1/2] Added CodedInputStream ctor symmetrical with CodedOutputStream. committer: Arnold Zokas --- src/ProtocolBuffers/CodedInputStream.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/ProtocolBuffers/CodedInputStream.cs b/src/ProtocolBuffers/CodedInputStream.cs index a929df2329..e20ad0bbda 100644 --- a/src/ProtocolBuffers/CodedInputStream.cs +++ b/src/ProtocolBuffers/CodedInputStream.cs @@ -105,13 +105,22 @@ namespace Google.ProtocolBuffers { /// byte array. /// public static CodedInputStream CreateInstance(byte[] buf) { - return new CodedInputStream(buf); + return new CodedInputStream(buf, 0, buf.Length); } - private CodedInputStream(byte[] buffer) { - this.buffer = buffer; - this.bufferSize = buffer.Length; - this.input = null; + /// + /// Creates a new CodedInputStream that reads from the given + /// byte array slice. + /// + public static CodedInputStream CreateInstance(byte[] buf, int offset, int length) { + return new CodedInputStream(buf, offset, length); + } + + private CodedInputStream(byte[] buffer, int offset, int length) { + this.buffer = buffer; + this.bufferPos = offset; + this.bufferSize = offset + length; + this.input = null; } private CodedInputStream(Stream input) { From be4b86aeae26ef068ff7dc9df880e81dc28dab1c Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 23 Nov 2010 05:47:50 +0800 Subject: [PATCH 2/2] Fixed spacing committer: Arnold Zokas --- src/ProtocolBuffers/CodedInputStream.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ProtocolBuffers/CodedInputStream.cs b/src/ProtocolBuffers/CodedInputStream.cs index e20ad0bbda..3306f309d4 100644 --- a/src/ProtocolBuffers/CodedInputStream.cs +++ b/src/ProtocolBuffers/CodedInputStream.cs @@ -113,14 +113,14 @@ namespace Google.ProtocolBuffers { /// byte array slice. /// public static CodedInputStream CreateInstance(byte[] buf, int offset, int length) { - return new CodedInputStream(buf, offset, length); + return new CodedInputStream(buf, offset, length); } private CodedInputStream(byte[] buffer, int offset, int length) { - this.buffer = buffer; - this.bufferPos = offset; - this.bufferSize = offset + length; - this.input = null; + this.buffer = buffer; + this.bufferPos = offset; + this.bufferSize = offset + length; + this.input = null; } private CodedInputStream(Stream input) {