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>
This commit is contained in:

committed by
Junio C Hamano

parent
f132a127ee
commit
837e34eba4
@ -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;
|
||||
|
Reference in New Issue
Block a user