mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 22:23:24 +00:00
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>
This commit is contained in:
parent
8c63d4e2bd
commit
d5e6a65944
1 changed files with 4 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue