Skip to content

Commit 269d2c8

Browse files
committed
Dont worry about pinnin anything
1 parent c863157 commit 269d2c8

File tree

2 files changed

+20
-74
lines changed

2 files changed

+20
-74
lines changed

LibGit2Sharp/Core/GitFilter.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,30 @@ internal class GitFilter
1313

1414
public IntPtr attributes;
1515

16-
public IntPtr init;
16+
//public IntPtr init;
1717

18-
public IntPtr shutdown;
18+
//public IntPtr shutdown;
1919

20-
public IntPtr check;
20+
//public IntPtr check;
2121

22-
public IntPtr apply;
22+
//public IntPtr apply;
2323

24-
public IntPtr cleanup;
24+
//public IntPtr cleanup;
2525

26-
//[MarshalAs(UnmanagedType.FunctionPtr)]
27-
//public git_filter_init_fn init;
26+
[MarshalAs(UnmanagedType.FunctionPtr)]
27+
public git_filter_init_fn init;
2828

29-
//[MarshalAs(UnmanagedType.FunctionPtr)]
30-
//public git_filter_shutdown_fn shutdown;
29+
[MarshalAs(UnmanagedType.FunctionPtr)]
30+
public git_filter_shutdown_fn shutdown;
3131

32-
//[MarshalAs(UnmanagedType.FunctionPtr)]
33-
//public git_filter_check_fn check;
32+
[MarshalAs(UnmanagedType.FunctionPtr)]
33+
public git_filter_check_fn check;
3434

35-
//[MarshalAs(UnmanagedType.FunctionPtr)]
36-
//public git_filter_apply_fn apply;
35+
[MarshalAs(UnmanagedType.FunctionPtr)]
36+
public git_filter_apply_fn apply;
3737

38-
//[MarshalAs(UnmanagedType.FunctionPtr)]
39-
//public git_filter_cleanup_fn cleanup;
38+
[MarshalAs(UnmanagedType.FunctionPtr)]
39+
public git_filter_cleanup_fn cleanup;
4040

4141
/* The libgit2 structure definition ends here. Subsequent fields are for libgit2sharp bookkeeping. */
4242

LibGit2Sharp/Filter.cs

Lines changed: 5 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public sealed class Filter : IEquatable<Filter>
2020
private readonly FilterCallbacks filterCallbacks;
2121

2222
private GitFilter managedFilter;
23-
private GCHandle filterHandle;
2423
private readonly GitFilterSafeHandle nativeFilter;
2524

2625
private GitFilter.git_filter_apply_fn applyCallback;
@@ -29,17 +28,6 @@ public sealed class Filter : IEquatable<Filter>
2928
private GitFilter.git_filter_shutdown_fn shutdownCallback;
3029
private GitFilter.git_filter_cleanup_fn cleanCallback;
3130

32-
private IntPtr applyCallbackHandle;
33-
private IntPtr checkCallbackHandle;
34-
private IntPtr initCallbackHandle;
35-
private GCHandle checkCallbackGCHandle;
36-
private GCHandle applyCallbackGCHandle;
37-
private GCHandle initCallbackGCHandle;
38-
private IntPtr shutdownCallbackHandle;
39-
private IntPtr cleanCallbackHandle;
40-
private GCHandle shutdownCallbackGCHandle;
41-
private GCHandle cleanCallbackGCHandle;
42-
4331
/// <summary>
4432
/// Initializes a new instance of the <see cref="Filter"/> class.
4533
/// And allocates the filter natively.
@@ -62,30 +50,18 @@ public Filter(string name, string attributes, int version, FilterCallbacks filte
6250
shutdownCallback = ShutdownCallback;
6351
cleanCallback = CleanUpCallback;
6452

65-
checkCallbackHandle = Marshal.GetFunctionPointerForDelegate(checkCallback);
66-
applyCallbackHandle = Marshal.GetFunctionPointerForDelegate(applyCallback);
67-
initCallbackHandle = Marshal.GetFunctionPointerForDelegate(initCallback);
68-
shutdownCallbackHandle = Marshal.GetFunctionPointerForDelegate(shutdownCallback);
69-
cleanCallbackHandle = Marshal.GetFunctionPointerForDelegate(cleanCallback);
70-
71-
checkCallbackGCHandle = GCHandle.Alloc(checkCallbackHandle, GCHandleType.Pinned);
72-
applyCallbackGCHandle = GCHandle.Alloc(applyCallbackHandle, GCHandleType.Pinned);
73-
initCallbackGCHandle = GCHandle.Alloc(initCallbackHandle, GCHandleType.Pinned);
74-
shutdownCallbackGCHandle = GCHandle.Alloc(shutdownCallbackHandle, GCHandleType.Pinned);
75-
cleanCallbackGCHandle = GCHandle.Alloc(cleanCallbackHandle, GCHandleType.Pinned);
7653

7754
managedFilter = new GitFilter
7855
{
7956
attributes = EncodingMarshaler.FromManaged(Encoding.UTF8, attributes),
8057
version = (uint)version,
81-
init = initCallbackHandle,
82-
apply = applyCallbackHandle,
83-
check = checkCallbackHandle,
84-
shutdown = shutdownCallbackHandle,
85-
cleanup = cleanCallbackHandle
58+
init = initCallback,
59+
apply = applyCallback,
60+
check = checkCallback,
61+
shutdown = shutdownCallback,
62+
cleanup = cleanCallback
8663
};
8764

88-
filterHandle = GCHandle.Alloc(managedFilter, GCHandleType.Pinned);
8965
nativeFilter = new GitFilterSafeHandle(managedFilter);
9066
}
9167

@@ -136,36 +112,6 @@ public void Register()
136112
public void Deregister()
137113
{
138114
Proxy.git_filter_unregister(name);
139-
140-
if (filterHandle.IsAllocated)
141-
{
142-
filterHandle.Free();
143-
}
144-
145-
if (applyCallbackGCHandle.IsAllocated)
146-
{
147-
applyCallbackGCHandle.Free();
148-
}
149-
150-
if (checkCallbackGCHandle.IsAllocated)
151-
{
152-
checkCallbackGCHandle.Free();
153-
}
154-
155-
if (initCallbackGCHandle.IsAllocated)
156-
{
157-
initCallbackGCHandle.Free();
158-
}
159-
160-
if (shutdownCallbackGCHandle.IsAllocated)
161-
{
162-
shutdownCallbackGCHandle.Free();
163-
}
164-
165-
if (cleanCallbackGCHandle.IsAllocated)
166-
{
167-
cleanCallbackGCHandle.Free();
168-
}
169115
}
170116

171117
/// <summary>

0 commit comments

Comments
 (0)