aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/csharp/Grpc.Core/Internal/MarshalUtils.cs
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2018-09-28 11:39:32 +0200
committerGravatar Jan Tattermusch <jtattermusch@google.com>2018-09-28 11:39:32 +0200
commitea5aa4a34af3f605d641d805889f005133512cec (patch)
tree233447c5bed91a1c91c86ea778c630420691237d /src/csharp/Grpc.Core/Internal/MarshalUtils.cs
parent59f8157123fa1f1040ee525f7886861850281809 (diff)
addressing a few nits
Diffstat (limited to 'src/csharp/Grpc.Core/Internal/MarshalUtils.cs')
-rw-r--r--src/csharp/Grpc.Core/Internal/MarshalUtils.cs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/csharp/Grpc.Core/Internal/MarshalUtils.cs b/src/csharp/Grpc.Core/Internal/MarshalUtils.cs
index 73b7a2ef95..09ded1a036 100644
--- a/src/csharp/Grpc.Core/Internal/MarshalUtils.cs
+++ b/src/csharp/Grpc.Core/Internal/MarshalUtils.cs
@@ -36,8 +36,12 @@ namespace Grpc.Core.Internal
public static string PtrToStringUTF8(IntPtr ptr, int len)
{
if (len == 0)
+ {
return "";
+ }
+ // TODO(jtattermusch): once Span dependency is added,
+ // use Span-based API to decode the string without copying the buffer.
var bytes = new byte[len];
Marshal.Copy(ptr, bytes, 0, len);
return EncodingUTF8.GetString(bytes);