00001 using System; 00002 using System.Runtime.InteropServices; 00003 00004 namespace SQLiteCSLib.Inner 00005 { 00009 public class StringToC : IDisposable 00010 { 00014 protected IntPtr m_cstr = IntPtr.Zero; 00015 00020 public StringToC( String str ) 00021 { 00022 m_cstr = Marshal.StringToHGlobalAuto(str); 00023 } 00024 00028 unsafe public void* CStr 00029 { 00030 get 00031 { 00032 return m_cstr.ToPointer(); 00033 } 00034 } 00035 00039 ‾StringToC() 00040 { 00041 Dispose(); 00042 } 00043 00047 public void Dispose() 00048 { 00049 if( m_cstr != IntPtr.Zero ) 00050 { 00051 Marshal.FreeHGlobal(m_cstr); 00052 m_cstr = IntPtr.Zero; 00053 } 00054 } 00055 } 00056 }