Fix memleaks in Tree.EntryBy(Name/Path/Index), fixes #313 #365

Merged
AaronO merged 2 commits from fix/memleak-tree-entrybyname into master 2017-04-13 14:16:31 -05:00
AaronO commented 2017-02-24 15:55:46 -06:00 (Migrated from github.com)

This fixes a memory leak in the following methods:

  • Tree.EntryByName()
  • Tree.EntryByPath()
  • Tree.EntryById()

This issue was previously reported in https://github.com/libgit2/git2go/issues/313

I decided to use defer calls because it's cleaner and more consistent with the conventions used inside the codebase (@carlosmn, you mentioned using a local var in #313).

In addition go1.8 has halved the costs of defer calls, I think correctness comes before speed (premature optimization).

This fixes a memory leak in the following methods: * `Tree.EntryByName()` * `Tree.EntryByPath()` * `Tree.EntryById()` This issue was previously reported in https://github.com/libgit2/git2go/issues/313 I decided to use `defer` calls because it's cleaner and more consistent with the conventions used inside the codebase (@carlosmn, you mentioned using a local var in #313). In addition `go1.8` has [halved the costs of defer calls](https://golang.org/doc/go1.8#defer), I think correctness comes before speed (premature optimization).
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: jcarr/git2go#365
No description provided.