Skip to content

Commit 690af70

Browse files
committed
Get rid of the branch iterator SafeHandle
1 parent 43521a6 commit 690af70

File tree

4 files changed

+9
-17
lines changed

4 files changed

+9
-17
lines changed

LibGit2Sharp/Core/Handles/BranchIteratorSafeHandle.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ internal static extern void git_branch_iterator_free(
166166
IntPtr iterator);
167167

168168
[DllImport(libgit2)]
169-
internal static extern int git_branch_iterator_new(
170-
out BranchIteratorSafeHandle iter_out,
169+
internal static extern int git_branch_iterator_new(
170+
out IntPtr iter_out,
171171
RepositorySafeHandle repo,
172172
GitBranchType branch_type);
173173

@@ -182,7 +182,7 @@ internal static extern unsafe int git_branch_move(
182182
internal static extern int git_branch_next(
183183
out IntPtr ref_out,
184184
out GitBranchType type_out,
185-
BranchIteratorSafeHandle iter);
185+
IntPtr iter);
186186

187187
[DllImport(libgit2)]
188188
internal static extern int git_branch_remote_name(

LibGit2Sharp/Core/Proxy.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,11 @@ public static unsafe void git_branch_delete(GitReferenceHandle reference)
211211

212212
public static IEnumerable<Branch> git_branch_iterator(Repository repo, GitBranchType branchType)
213213
{
214-
BranchIteratorSafeHandle iter;
214+
IntPtr iter;
215215
var res = NativeMethods.git_branch_iterator_new(out iter, repo.Handle, branchType);
216216
Ensure.ZeroResult(res);
217217

218-
using (iter)
218+
try
219219
{
220220
while (true)
221221
{
@@ -236,6 +236,10 @@ public static IEnumerable<Branch> git_branch_iterator(Repository repo, GitBranch
236236
yield return new Branch(repo, reference, reference.CanonicalName);
237237
}
238238
}
239+
finally
240+
{
241+
NativeMethods.git_branch_iterator_free(iter);
242+
}
239243
}
240244

241245
public static void git_branch_iterator_free(IntPtr iter)

LibGit2Sharp/LibGit2Sharp.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@
147147
<Compile Include="RefSpecCollection.cs" />
148148
<Compile Include="Core\EncodingMarshaler.cs" />
149149
<Compile Include="Core\GitMergeOpts.cs" />
150-
<Compile Include="Core\Handles\BranchIteratorSafeHandle.cs" />
151150
<Compile Include="Core\Handles\ConfigurationIteratorSafeHandle.cs" />
152151
<Compile Include="Core\GitBlame.cs" />
153152
<Compile Include="Core\Handles\BlameSafeHandle.cs" />

0 commit comments

Comments
 (0)