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>2011-06-18 08:49:46 +0400
committernulltoken <emeric.fermas@gmail.com>2011-06-19 10:46:17 +0400
commitc3c806c5ec701d0dabb231396b7b06a9671fe1ee (patch)
tree8eafad02bc0c3079f5cd68739d46a3131bc22913
parentbf9ffdc41406c60d74e75f5049e8506d8dd282e1 (diff)
Improve handling of interop of libgit2
Should fix issue #46. Credit goes to @txdv for having spotted this.
-rw-r--r--LibGit2Sharp/Core/Libgit2UnsafeHelper.cs18
-rw-r--r--LibGit2Sharp/Core/UnSafeNativeMethods.cs6
2 files changed, 13 insertions, 11 deletions
diff --git a/LibGit2Sharp/Core/Libgit2UnsafeHelper.cs b/LibGit2Sharp/Core/Libgit2UnsafeHelper.cs
index c06fefc6..d4663dfe 100644
--- a/LibGit2Sharp/Core/Libgit2UnsafeHelper.cs
+++ b/LibGit2Sharp/Core/Libgit2UnsafeHelper.cs
@@ -7,37 +7,39 @@ namespace LibGit2Sharp.Core
public static IList<string> ListAllReferenceNames(RepositorySafeHandle repo, GitReferenceType types)
{
UnSafeNativeMethods.git_strarray strArray;
- var res = UnSafeNativeMethods.git_reference_listall(&strArray, repo, types);
+ var res = UnSafeNativeMethods.git_reference_listall(out strArray, repo, types);
Ensure.Success(res);
- return BuildListOf(&strArray);
+ return BuildListOf(strArray);
}
public static IList<string> ListAllTagNames(RepositorySafeHandle repo)
{
UnSafeNativeMethods.git_strarray strArray;
- var res = UnSafeNativeMethods.git_tag_list(&strArray, repo);
+ var res = UnSafeNativeMethods.git_tag_list(out strArray, repo);
Ensure.Success(res);
- return BuildListOf(&strArray);
+ return BuildListOf(strArray);
}
- private static IList<string> BuildListOf(UnSafeNativeMethods.git_strarray* strArray)
+ private static IList<string> BuildListOf(UnSafeNativeMethods.git_strarray strArray)
{
var list = new List<string>();
try
{
- int numberOfEntries = strArray->size.ToInt32();
+ UnSafeNativeMethods.git_strarray* gitStrArray = &strArray;
+
+ int numberOfEntries = gitStrArray->size.ToInt32();
for (uint i = 0; i < numberOfEntries; i++)
{
- var name = new string(strArray->strings[i]);
+ var name = new string(gitStrArray->strings[i]);
list.Add(name);
}
}
finally
{
- UnSafeNativeMethods.git_strarray_free(strArray);
+ UnSafeNativeMethods.git_strarray_free(ref strArray);
}
return list;
diff --git a/LibGit2Sharp/Core/UnSafeNativeMethods.cs b/LibGit2Sharp/Core/UnSafeNativeMethods.cs
index 2df76a61..dbb27c48 100644
--- a/LibGit2Sharp/Core/UnSafeNativeMethods.cs
+++ b/LibGit2Sharp/Core/UnSafeNativeMethods.cs
@@ -8,13 +8,13 @@ namespace LibGit2Sharp.Core
private const string libgit2 = "git2";
[DllImport(libgit2)]
- public static extern int git_reference_listall(git_strarray* array, RepositorySafeHandle repo, GitReferenceType flags);
+ public static extern int git_reference_listall(out git_strarray array, RepositorySafeHandle repo, GitReferenceType flags);
[DllImport(libgit2)]
- public static extern int git_tag_list(git_strarray* array, RepositorySafeHandle repo);
+ public static extern int git_tag_list(out git_strarray array, RepositorySafeHandle repo);
[DllImport(libgit2)]
- public static extern void git_strarray_free(git_strarray* array);
+ public static extern void git_strarray_free(ref git_strarray array);
#region Nested type: git_strarray