зеркало из https://github.com/github/libgit2sharp.git
Introduce EncodingMarshaler.Cleanup()
This commit is contained in:
Родитель
11f4cb81f0
Коммит
75eaceb3b4
|
@ -21,12 +21,7 @@ namespace LibGit2Sharp.Core
|
|||
|
||||
public virtual void CleanUpNativeData(IntPtr pNativeData)
|
||||
{
|
||||
if (pNativeData == IntPtr.Zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Marshal.FreeHGlobal(pNativeData);
|
||||
Cleanup(pNativeData);
|
||||
}
|
||||
|
||||
public int GetNativeDataSize()
|
||||
|
@ -83,6 +78,16 @@ namespace LibGit2Sharp.Core
|
|||
return new IntPtr(buffer);
|
||||
}
|
||||
|
||||
public static void Cleanup(IntPtr pNativeData)
|
||||
{
|
||||
if (pNativeData == IntPtr.Zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Marshal.FreeHGlobal(pNativeData);
|
||||
}
|
||||
|
||||
public static unsafe String FromNative(Encoding encoding, IntPtr pNativeData)
|
||||
{
|
||||
if (pNativeData == IntPtr.Zero)
|
||||
|
|
|
@ -41,12 +41,7 @@ namespace LibGit2Sharp.Core
|
|||
|
||||
public void Dispose()
|
||||
{
|
||||
if (WorkDirPath == IntPtr.Zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Marshal.FreeHGlobal(WorkDirPath);
|
||||
EncodingMarshaler.Cleanup(WorkDirPath);
|
||||
WorkDirPath = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace LibGit2Sharp.Core
|
|||
|
||||
for (int i = 0; i < nbOfPaths; i++)
|
||||
{
|
||||
Marshal.FreeHGlobal(pathPtrs[i]);
|
||||
EncodingMarshaler.Cleanup(pathPtrs[i]);
|
||||
}
|
||||
|
||||
Marshal.FreeHGlobal(strings);
|
||||
|
|
|
@ -5,7 +5,6 @@ using System.Diagnostics;
|
|||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using LibGit2Sharp.Core;
|
||||
using LibGit2Sharp.Core.Compat;
|
||||
using LibGit2Sharp.Core.Handles;
|
||||
|
@ -554,7 +553,7 @@ namespace LibGit2Sharp
|
|||
};
|
||||
|
||||
Proxy.git_index_add(handle, indexEntry);
|
||||
Marshal.FreeHGlobal(indexEntry.Path);
|
||||
EncodingMarshaler.Cleanup(indexEntry.Path);
|
||||
}
|
||||
|
||||
internal void ReloadFromDisk()
|
||||
|
|
Загрузка…
Ссылка в новой задаче