Skip to content

Better safehandles #2130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use handle directly in ReleaseHandle
  • Loading branch information
bording committed Nov 26, 2024
commit cf31b8f317f9de3067d495083b40728b20753cc6
50 changes: 25 additions & 25 deletions LibGit2Sharp/Core/Handles/Objects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal TreeEntryHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_tree_entry_free((git_tree_entry*)AsIntPtr());
NativeMethods.git_tree_entry_free((git_tree_entry*)handle);

return true;
}
Expand All @@ -43,7 +43,7 @@ internal ReferenceHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_reference_free((git_reference*)AsIntPtr());
NativeMethods.git_reference_free((git_reference*)handle);

return true;
}
Expand All @@ -68,7 +68,7 @@ internal RepositoryHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_repository_free((git_repository*)AsIntPtr());
NativeMethods.git_repository_free((git_repository*)handle);

return true;
}
Expand All @@ -93,7 +93,7 @@ internal SignatureHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_signature_free((git_signature*)AsIntPtr());
NativeMethods.git_signature_free((git_signature*)handle);

return true;
}
Expand All @@ -118,7 +118,7 @@ internal StatusListHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_status_list_free((git_status_list*)AsIntPtr());
NativeMethods.git_status_list_free((git_status_list*)handle);

return true;
}
Expand All @@ -143,7 +143,7 @@ internal BlameHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_blame_free((git_blame*)AsIntPtr());
NativeMethods.git_blame_free((git_blame*)handle);

return true;
}
Expand All @@ -168,7 +168,7 @@ internal DiffHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_diff_free((git_diff*)AsIntPtr());
NativeMethods.git_diff_free((git_diff*)handle);

return true;
}
Expand All @@ -193,7 +193,7 @@ internal PatchHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_patch_free((git_patch*)AsIntPtr());
NativeMethods.git_patch_free((git_patch*)handle);

return true;
}
Expand All @@ -218,7 +218,7 @@ internal ConfigurationHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_config_free((git_config*)AsIntPtr());
NativeMethods.git_config_free((git_config*)handle);

return true;
}
Expand All @@ -243,7 +243,7 @@ internal ConflictIteratorHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_index_conflict_iterator_free((git_index_conflict_iterator*)AsIntPtr());
NativeMethods.git_index_conflict_iterator_free((git_index_conflict_iterator*)handle);

return true;
}
Expand All @@ -268,7 +268,7 @@ internal IndexHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_index_free((git_index*)AsIntPtr());
NativeMethods.git_index_free((git_index*)handle);

return true;
}
Expand All @@ -293,7 +293,7 @@ internal ReflogHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_reflog_free((git_reflog*)AsIntPtr());
NativeMethods.git_reflog_free((git_reflog*)handle);

return true;
}
Expand All @@ -318,7 +318,7 @@ internal TreeBuilderHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_treebuilder_free((git_treebuilder*)AsIntPtr());
NativeMethods.git_treebuilder_free((git_treebuilder*)handle);

return true;
}
Expand All @@ -343,7 +343,7 @@ internal PackBuilderHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_packbuilder_free((git_packbuilder*)AsIntPtr());
NativeMethods.git_packbuilder_free((git_packbuilder*)handle);

return true;
}
Expand All @@ -368,7 +368,7 @@ internal NoteHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_note_free((git_note*)AsIntPtr());
NativeMethods.git_note_free((git_note*)handle);

return true;
}
Expand All @@ -393,7 +393,7 @@ internal DescribeResultHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_describe_result_free((git_describe_result*)AsIntPtr());
NativeMethods.git_describe_result_free((git_describe_result*)handle);

return true;
}
Expand All @@ -418,7 +418,7 @@ internal SubmoduleHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_submodule_free((git_submodule*)AsIntPtr());
NativeMethods.git_submodule_free((git_submodule*)handle);

return true;
}
Expand All @@ -443,7 +443,7 @@ internal AnnotatedCommitHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_annotated_commit_free((git_annotated_commit*)AsIntPtr());
NativeMethods.git_annotated_commit_free((git_annotated_commit*)handle);

return true;
}
Expand All @@ -468,7 +468,7 @@ internal ObjectDatabaseHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_odb_free((git_odb*)AsIntPtr());
NativeMethods.git_odb_free((git_odb*)handle);

return true;
}
Expand All @@ -493,7 +493,7 @@ internal RevWalkerHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_revwalk_free((git_revwalk*)AsIntPtr());
NativeMethods.git_revwalk_free((git_revwalk*)handle);

return true;
}
Expand All @@ -518,7 +518,7 @@ internal RemoteHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_remote_free((git_remote*)AsIntPtr());
NativeMethods.git_remote_free((git_remote*)handle);

return true;
}
Expand All @@ -543,7 +543,7 @@ internal ObjectHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_object_free((git_object*)AsIntPtr());
NativeMethods.git_object_free((git_object*)handle);

return true;
}
Expand All @@ -568,7 +568,7 @@ internal RebaseHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_rebase_free((git_rebase*)AsIntPtr());
NativeMethods.git_rebase_free((git_rebase*)handle);

return true;
}
Expand All @@ -593,7 +593,7 @@ internal OdbStreamHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_odb_stream_free((git_odb_stream*)AsIntPtr());
NativeMethods.git_odb_stream_free((git_odb_stream*)handle);

return true;
}
Expand All @@ -618,7 +618,7 @@ internal WorktreeHandle(IntPtr ptr, bool owned)

protected override bool ReleaseHandle()
{
NativeMethods.git_worktree_free((git_worktree*)AsIntPtr());
NativeMethods.git_worktree_free((git_worktree*)handle);

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/Core/Handles/Objects.tt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ for (var i = 0; i < cNames.Length; i++)

protected override bool ReleaseHandle()
{
NativeMethods.<#= cNames[i] #>_free((<#= cNames[i] #>*)AsIntPtr());
NativeMethods.<#= cNames[i] #>_free((<#= cNames[i] #>*)handle);

return true;
}
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy