diff options
author | Jan Tattermusch <jtattermusch@google.com> | 2015-07-20 20:28:28 -0700 |
---|---|---|
committer | Jan Tattermusch <jtattermusch@google.com> | 2015-07-20 20:28:28 -0700 |
commit | 7f23a75422aea6181c35857dd6f7936d1523fcd8 (patch) | |
tree | d3cca31dc8838959cb9cf59dcfff6d759bb14717 | |
parent | 77415b63bbad2d8a6cbcf610c07da958d34f87f0 (diff) |
fix bug
-rw-r--r-- | src/csharp/Grpc.Core.Tests/Internal/MetadataArraySafeHandleTest.cs | 21 | ||||
-rw-r--r-- | src/csharp/ext/grpc_csharp_ext.c | 4 |
2 files changed, 23 insertions, 2 deletions
diff --git a/src/csharp/Grpc.Core.Tests/Internal/MetadataArraySafeHandleTest.cs b/src/csharp/Grpc.Core.Tests/Internal/MetadataArraySafeHandleTest.cs index e03e20c4f7..46469113c5 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/MetadataArraySafeHandleTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/MetadataArraySafeHandleTest.cs @@ -59,5 +59,26 @@ namespace Grpc.Core.Internal.Tests var nativeMetadata = MetadataArraySafeHandle.Create(metadata); nativeMetadata.Dispose(); } + + [Test] + public void ReadMetadataFromPtrUnsafe() + { + var metadata = new Metadata + { + new Metadata.Entry("host", "somehost"), + new Metadata.Entry("header2", "header value"), + }; + var nativeMetadata = MetadataArraySafeHandle.Create(metadata); + + var copy = MetadataArraySafeHandle.ReadMetadataFromPtrUnsafe(nativeMetadata.Handle); + Assert.AreEqual(2, copy.Count); + + Assert.AreEqual("host", copy[0].Key); + Assert.AreEqual("somehost", copy[0].Value); + Assert.AreEqual("header2", copy[1].Key); + Assert.AreEqual("header value", copy[1].Value); + + nativeMetadata.Dispose(); + } } } diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index cfd96d15f1..6856d89ff1 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -172,10 +172,10 @@ grpcsharp_metadata_array_count(grpc_metadata_array *array) { return (gpr_intptr) array->count; } -GPR_EXPORT const grpc_metadata *GPR_CALLTYPE +GPR_EXPORT grpc_metadata GPR_CALLTYPE grpcsharp_metadata_array_get(grpc_metadata_array *array, size_t index) { GPR_ASSERT(index < array->count); - return &(array->metadata[index]); + return array->metadata[index]; } /* Move contents of metadata array */ |