summaryrefslogtreecommitdiffstats
path: root/core/load-git.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-04-04 12:22:50 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-04-04 10:13:14 -0700
commitd5e6a6594479b50a8d0f0d400e0c2dd3b8247db4 (patch)
tree9545731770184f2d0ac897c7429bc63288d6e5d5 /core/load-git.c
parent8c63d4e2bddbd5e5b1c4b58c254151675dcd4ca5 (diff)
downloadsubsurface-d5e6a6594479b50a8d0f0d400e0c2dd3b8247db4.tar.gz
cleanup: copy saved_git_id, don't use local buffer
In an attempt to reduce the number of global variables, don't use a local buffer to store the currently loaded git-id. The git-id itself is still a global variable, which in the future can hopefully be encapsulated in a "struct File" or similar. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/load-git.c')
-rw-r--r--core/load-git.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/load-git.c b/core/load-git.c
index f01fe72a0..cc6f42ce3 100644
--- a/core/load-git.c
+++ b/core/load-git.c
@@ -1677,15 +1677,17 @@ static int load_dives_from_tree(git_repository *repo, git_tree *tree, struct git
void clear_git_id(void)
{
+ free((void *)saved_git_id);
saved_git_id = NULL;
}
void set_git_id(const struct git_oid *id)
{
- static char git_id_buffer[GIT_OID_HEXSZ + 1];
+ char git_id_buffer[GIT_OID_HEXSZ + 1];
git_oid_tostr(git_id_buffer, sizeof(git_id_buffer), id);
- saved_git_id = git_id_buffer;
+ free((void *)saved_git_id);
+ saved_git_id = strdup(git_id_buffer);
}
static int find_commit(git_repository *repo, const char *branch, git_commit **commit_p)