Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ågren <martin.agren@gmail.com>2017-10-05 23:32:04 +0300
committerJunio C Hamano <gitster@pobox.com>2017-10-06 04:07:17 +0300
commit837e34eba47f209a38fc9ab458bd103fd7515325 (patch)
treeab91a9de784eec03c56b431b51dd4649270cfd9c /merge.c
parentf132a127eebb8f1b14b87fc317ca68278fceb2e8 (diff)
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.c')
-rw-r--r--merge.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/merge.c b/merge.c
index 1d441ad942..a18a452b5c 100644
--- a/merge.c
+++ b/merge.c
@@ -53,11 +53,11 @@ int checkout_fast_forward(const struct object_id *head,
struct tree_desc t[MAX_UNPACK_TREES];
int i, nr_trees = 0;
struct dir_struct dir;
- struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
+ struct lock_file lock_file = LOCK_INIT;
refresh_cache(REFRESH_QUIET);
- if (hold_locked_index(lock_file, LOCK_REPORT_ON_ERROR) < 0)
+ if (hold_locked_index(&lock_file, LOCK_REPORT_ON_ERROR) < 0)
return -1;
memset(&trees, 0, sizeof(trees));
@@ -91,8 +91,8 @@ int checkout_fast_forward(const struct object_id *head,
}
if (unpack_trees(nr_trees, t, &opts))
return -1;
- if (write_locked_index(&the_index, lock_file, COMMIT_LOCK)) {
- rollback_lock_file(lock_file);
+ if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK)) {
+ rollback_lock_file(&lock_file);
return error(_("unable to write new index file"));
}
return 0;