mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-08 10:11:11 +00:00
index: introduce index_entry_free()
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
This commit is contained in:
parent
51917d9ca2
commit
b2dd681512
14
src/index.c
14
src/index.c
@ -349,6 +349,14 @@ static git_index_entry *index_entry_dup(const git_index_entry *source_entry)
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void index_entry_free(git_index_entry *entry)
|
||||||
|
{
|
||||||
|
if (!entry)
|
||||||
|
return;
|
||||||
|
free(entry->path);
|
||||||
|
free(entry);
|
||||||
|
}
|
||||||
|
|
||||||
static int index_insert(git_index *index, const git_index_entry *source_entry, int replace)
|
static int index_insert(git_index *index, const git_index_entry *source_entry, int replace)
|
||||||
{
|
{
|
||||||
git_index_entry *entry;
|
git_index_entry *entry;
|
||||||
@ -402,15 +410,13 @@ static int index_insert(git_index *index, const git_index_entry *source_entry, i
|
|||||||
|
|
||||||
/* exists, replace it */
|
/* exists, replace it */
|
||||||
entry_array = (git_index_entry **) index->entries.contents;
|
entry_array = (git_index_entry **) index->entries.contents;
|
||||||
free(entry_array[position]->path);
|
index_entry_free(entry_array[position]);
|
||||||
free(entry_array[position]);
|
|
||||||
entry_array[position] = entry;
|
entry_array[position] = entry;
|
||||||
|
|
||||||
return GIT_SUCCESS;
|
return GIT_SUCCESS;
|
||||||
|
|
||||||
cleanup_oom:
|
cleanup_oom:
|
||||||
free(entry->path);
|
index_entry_free(entry);
|
||||||
free(entry);
|
|
||||||
return GIT_ENOMEM;;
|
return GIT_ENOMEM;;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user