[vlc-devel] commit: Safe handle class for LibVLC heap allocation ( Rémi Denis-Courmont )
git version control
git at videolan.org
Sat Feb 21 17:15:15 CET 2009
vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sat Feb 21 16:42:09 2009 +0200| [73f14c799831112f1b3612314606d6e317b0d5b8] | committer: Rémi Denis-Courmont
Safe handle class for LibVLC heap allocation
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=73f14c799831112f1b3612314606d6e317b0d5b8
---
bindings/cil/src/libvlc.cs | 2 +-
bindings/cil/src/ustring.cs | 32 +++++++++++++++++++++++++++++++-
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/bindings/cil/src/libvlc.cs b/bindings/cil/src/libvlc.cs
index 6087453..1728cc9 100644
--- a/bindings/cil/src/libvlc.cs
+++ b/bindings/cil/src/libvlc.cs
@@ -98,7 +98,7 @@ namespace VideoLAN.LibVLC
[DllImport ("libvlc.dll", EntryPoint="libvlc_media_get_mrl")]
public static extern
- void MediaGetMRL (MediaHandle media);
+ MemoryHandle MediaGetMRL (MediaHandle media, NativeException ex);
[DllImport ("libvlc.dll", EntryPoint="libvlc_media_duplicate")]
public static extern
diff --git a/bindings/cil/src/ustring.cs b/bindings/cil/src/ustring.cs
index a605b8f..d6ad65a 100644
--- a/bindings/cil/src/ustring.cs
+++ b/bindings/cil/src/ustring.cs
@@ -33,7 +33,7 @@ namespace VideoLAN.LibVLC
* arrays (as used by the native LibVLC) and managed strings.
*/
[StructLayout (LayoutKind.Sequential)]
- public struct U8String
+ internal struct U8String
{
public byte[] mb_str; /**< nul-terminated UTF-8 bytes array */
@@ -91,4 +91,34 @@ namespace VideoLAN.LibVLC
return new U8String (ptr).ToString ();
}
};
+
+ /**
+ * @brief MemoryHandle: heap allocation by the C run-time
+ * @ingroup Internals
+ */
+ internal sealed class MemoryHandle : NonNullHandle
+ {
+ [DllImport ("libvlc.dll", EntryPoint="libvlc_free")]
+ private static extern void Free (IntPtr ptr);
+
+ /**
+ * NonNullHandle.Destroy
+ */
+ protected override void Destroy ()
+ {
+ Free (handle);
+ }
+
+ public override string ToString ()
+ {
+ return U8String.FromNative (handle);
+ }
+
+ public string Transform ()
+ {
+ string value = ToString ();
+ Close ();
+ return value;
+ }
+ };
};
More information about the vlc-devel
mailing list