Index: third_party/grpc/src/csharp/Grpc.Core/Internal/CStringSafeHandle.cs |
diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/SampleEnum.cs b/third_party/grpc/src/csharp/Grpc.Core/Internal/CStringSafeHandle.cs |
similarity index 70% |
copy from third_party/protobuf/csharp/src/Google.Protobuf.Test/SampleEnum.cs |
copy to third_party/grpc/src/csharp/Grpc.Core/Internal/CStringSafeHandle.cs |
index 77447afa127340046298081d9bfca4dd51c14f6c..4ae57aa773aba8d6623163c48cc549f171316c01 100644 |
--- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/SampleEnum.cs |
+++ b/third_party/grpc/src/csharp/Grpc.Core/Internal/CStringSafeHandle.cs |
@@ -1,7 +1,6 @@ |
#region Copyright notice and license |
-// Protocol Buffers - Google's data interchange format |
-// Copyright 2015 Google Inc. All rights reserved. |
-// https://developers.google.com/protocol-buffers/ |
+// Copyright 2015-2016, Google Inc. |
+// All rights reserved. |
// |
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
@@ -29,14 +28,32 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
#endregion |
- |
-namespace Google.Protobuf |
+using System; |
+using System.Runtime.InteropServices; |
+using System.Threading.Tasks; |
+ |
+namespace Grpc.Core.Internal |
{ |
- // Just a sample enum with positive and negative values to be used in tests. |
- internal enum SampleEnum |
+ /// <summary> |
+ /// Owned char* object. |
+ /// </summary> |
+ internal class CStringSafeHandle : SafeHandleZeroIsInvalid |
{ |
- NegativeValue = -2, |
- None = 0, |
- PositiveValue = 3 |
+ static readonly NativeMethods Native = NativeMethods.Get(); |
+ |
+ private CStringSafeHandle() |
+ { |
+ } |
+ |
+ public string GetValue() |
+ { |
+ return Marshal.PtrToStringAnsi(handle); |
+ } |
+ |
+ protected override bool ReleaseHandle() |
+ { |
+ Native.gprsharp_free(handle); |
+ return true; |
+ } |
} |
} |