Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2012-03-28 19:34:57 +0400
committernulltoken <emeric.fermas@gmail.com>2012-03-28 22:02:17 +0400
commitb94a1113dc5e7c6377e7300150784f7fc16f3dac (patch)
tree9cdb572f5b66c94543622af708d22b4788b02d3c /LibGit2Sharp
parent61976902d1f22eb5056e7380a28949426a9990bc (diff)
Replace usage of IntPtr holding references to index entries with IndexEntrySafeHandle
Diffstat (limited to 'LibGit2Sharp')
-rw-r--r--LibGit2Sharp/Core/NativeMethods.cs2
-rw-r--r--LibGit2Sharp/Index.cs5
-rw-r--r--LibGit2Sharp/IndexEntry.cs6
3 files changed, 8 insertions, 5 deletions
diff --git a/LibGit2Sharp/Core/NativeMethods.cs b/LibGit2Sharp/Core/NativeMethods.cs
index 242148fd..3f4eb4b7 100644
--- a/LibGit2Sharp/Core/NativeMethods.cs
+++ b/LibGit2Sharp/Core/NativeMethods.cs
@@ -189,7 +189,7 @@ namespace LibGit2Sharp.Core
public static extern void git_index_free(IntPtr index);
[DllImport(libgit2)]
- public static extern IntPtr git_index_get(IndexSafeHandle index, uint n);
+ public static extern IndexEntrySafeHandle git_index_get(IndexSafeHandle index, uint n);
[DllImport(libgit2)]
public static extern int git_index_read_tree(IndexSafeHandle index, GitObjectSafeHandle tree);
diff --git a/LibGit2Sharp/Index.cs b/LibGit2Sharp/Index.cs
index 15dbfba6..e380031b 100644
--- a/LibGit2Sharp/Index.cs
+++ b/LibGit2Sharp/Index.cs
@@ -5,6 +5,7 @@ using System.Globalization;
using System.IO;
using LibGit2Sharp.Core;
using LibGit2Sharp.Core.Compat;
+using LibGit2Sharp.Core.Handles;
namespace LibGit2Sharp
{
@@ -67,8 +68,8 @@ namespace LibGit2Sharp
{
get
{
- IntPtr entryPtr = NativeMethods.git_index_get(handle, index);
- return IndexEntry.CreateFromPtr(repo, entryPtr);
+ IndexEntrySafeHandle entryHandle = NativeMethods.git_index_get(handle, index);
+ return IndexEntry.CreateFromPtr(repo, entryHandle);
}
}
diff --git a/LibGit2Sharp/IndexEntry.cs b/LibGit2Sharp/IndexEntry.cs
index 6749a7db..8bb5ea46 100644
--- a/LibGit2Sharp/IndexEntry.cs
+++ b/LibGit2Sharp/IndexEntry.cs
@@ -1,6 +1,7 @@
using System;
using System.Runtime.InteropServices;
using LibGit2Sharp.Core;
+using LibGit2Sharp.Core.Handles;
namespace LibGit2Sharp
{
@@ -35,9 +36,10 @@ namespace LibGit2Sharp
/// </summary>
public ObjectId Id { get; private set; }
- internal static IndexEntry CreateFromPtr(Repository repo, IntPtr ptr)
+ internal static IndexEntry CreateFromPtr(Repository repo, IndexEntrySafeHandle handle)
{
- var entry = (GitIndexEntry)Marshal.PtrToStructure(ptr, typeof(GitIndexEntry));
+ GitIndexEntry entry = handle.MarshalAsGitIndexEntry();
+
FilePath path = (string)marshaler.MarshalNativeToManaged(entry.Path);
return new IndexEntry