summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorMartin Ågren <martin.agren@gmail.com>2017-10-05 20:32:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-10-06 01:07:17 (GMT)
commit837e34eba47f209a38fc9ab458bd103fd7515325 (patch)
treeab91a9de784eec03c56b431b51dd4649270cfd9c /merge-recursive.c
parentf132a127eebb8f1b14b87fc317ca68278fceb2e8 (diff)
downloadgit-837e34eba47f209a38fc9ab458bd103fd7515325.zip
git-837e34eba47f209a38fc9ab458bd103fd7515325.tar.gz
git-837e34eba47f209a38fc9ab458bd103fd7515325.tar.bz2
treewide: prefer lockfiles on the stack
There is no longer any need to allocate and leak a `struct lock_file`. The previous patch addressed an instance where we needed a minor tweak alongside the trivial changes. Deal with the remaining instances where we allocate and leak a struct within a single function. Change them to have the `struct lock_file` on the stack instead. These instances were identified by running `git grep "^\s*struct lock_file\s*\*"`. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-recursive.c')
-rw-r--r--merge-recursive.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index 1d3f8f0..24c5c26 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -2162,7 +2162,7 @@ int merge_recursive_generic(struct merge_options *o,
struct commit **result)
{
int clean;
- struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
+ struct lock_file lock = LOCK_INIT;
struct commit *head_commit = get_ref(head, o->branch1);
struct commit *next_commit = get_ref(merge, o->branch2);
struct commit_list *ca = NULL;
@@ -2178,14 +2178,14 @@ int merge_recursive_generic(struct merge_options *o,
}
}
- hold_locked_index(lock, LOCK_DIE_ON_ERROR);
+ hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
clean = merge_recursive(o, head_commit, next_commit, ca,
result);
if (clean < 0)
return clean;
if (active_cache_changed &&
- write_locked_index(&the_index, lock, COMMIT_LOCK))
+ write_locked_index(&the_index, &lock, COMMIT_LOCK))
return err(o, _("Unable to write index."));
return clean ? 0 : 1;