Commit 98743759 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Separate MemoryHandle and StringHandle

parent 247431e0
...@@ -98,7 +98,7 @@ namespace VideoLAN.LibVLC ...@@ -98,7 +98,7 @@ namespace VideoLAN.LibVLC
[DllImport ("libvlc.dll", EntryPoint="libvlc_media_get_mrl")] [DllImport ("libvlc.dll", EntryPoint="libvlc_media_get_mrl")]
public static extern public static extern
MemoryHandle MediaGetMRL (MediaHandle media, NativeException ex); StringHandle MediaGetMRL (MediaHandle media, NativeException ex);
[DllImport ("libvlc.dll", EntryPoint="libvlc_media_duplicate")] [DllImport ("libvlc.dll", EntryPoint="libvlc_media_duplicate")]
public static extern public static extern
......
...@@ -102,7 +102,7 @@ namespace VideoLAN.LibVLC ...@@ -102,7 +102,7 @@ namespace VideoLAN.LibVLC
{ {
get get
{ {
MemoryHandle str = LibVLC.MediaGetMRL (Handle, ex); StringHandle str = LibVLC.MediaGetMRL (Handle, ex);
Raise (); Raise ();
return str.Transform (); return str.Transform ();
} }
......
...@@ -96,7 +96,7 @@ namespace VideoLAN.LibVLC ...@@ -96,7 +96,7 @@ namespace VideoLAN.LibVLC
* @brief MemoryHandle: heap allocation by the C run-time * @brief MemoryHandle: heap allocation by the C run-time
* @ingroup Internals * @ingroup Internals
*/ */
internal sealed class MemoryHandle : NonNullHandle internal class MemoryHandle : NonNullHandle
{ {
[DllImport ("libvlc.dll", EntryPoint="libvlc_free")] [DllImport ("libvlc.dll", EntryPoint="libvlc_free")]
private static extern void Free (IntPtr ptr); private static extern void Free (IntPtr ptr);
...@@ -108,7 +108,19 @@ namespace VideoLAN.LibVLC ...@@ -108,7 +108,19 @@ namespace VideoLAN.LibVLC
{ {
Free (handle); Free (handle);
} }
};
/**
* @brief StringHandle: heap-allocated characters array
* @ingroup Internals
*/
internal sealed class StringHandle : MemoryHandle
{
/**
* Converts an heap-allocated nul-terminated UTF-8 characters array
* into a managed string.
* @return the resulting managed string.
*/
public override string ToString () public override string ToString ()
{ {
return U8String.FromNative (handle); return U8String.FromNative (handle);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment