diff options
author | nulltoken <emeric.fermas@gmail.com> | 2012-04-15 23:39:43 +0400 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2012-04-24 12:51:42 +0400 |
commit | 58a11459cf54041eec11e3f6cde2b815fd707aa8 (patch) | |
tree | a5cdb908d60c8af507debd828e4806ec96200e39 | |
parent | 9444c7e40a9ef1fac18f71b7805e5e216f00839a (diff) |
Reverse the order in which the native handles are being released
-rw-r--r-- | LibGit2Sharp/Repository.cs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs index 41fdc6e9..e49e8c0d 100644 --- a/LibGit2Sharp/Repository.cs +++ b/LibGit2Sharp/Repository.cs @@ -23,7 +23,7 @@ namespace LibGit2Sharp private readonly TagCollection tags; private readonly Lazy<RepositoryInformation> info; private readonly bool isBare; - private readonly List<SafeHandleBase> handlesToCleanup = new List<SafeHandleBase>(); + private readonly Stack<SafeHandleBase> handlesToCleanup = new Stack<SafeHandleBase>(); private static readonly Lazy<string> versionRetriever = new Lazy<string>(RetrieveVersion); /// <summary> @@ -177,7 +177,10 @@ namespace LibGit2Sharp /// </summary> protected virtual void Dispose(bool disposing) { - handlesToCleanup.ForEach(handleToCleanup => handleToCleanup.SafeDispose()); + while (handlesToCleanup.Count > 0) + { + handlesToCleanup.Pop().SafeDispose(); + } } #endregion @@ -413,7 +416,7 @@ namespace LibGit2Sharp internal void RegisterForCleanup(SafeHandleBase handleToCleanup) { - handlesToCleanup.Add(handleToCleanup); + handlesToCleanup.Push(handleToCleanup); } /// <summary> |