Skip to content

Commit

Permalink
index: introduce index_entry_free()
Browse files Browse the repository at this point in the history
Signed-off-by: Kirill A. Shutemov <[email protected]>
  • Loading branch information
kiryl authored and vmg committed Jul 25, 2011
1 parent 51917d9 commit b2dd681
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/index.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,14 @@ static git_index_entry *index_entry_dup(const git_index_entry *source_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)
{
git_index_entry *entry;
Expand Down Expand Up @@ -402,15 +410,13 @@ static int index_insert(git_index *index, const git_index_entry *source_entry, i

/* exists, replace it */
entry_array = (git_index_entry **) index->entries.contents;
free(entry_array[position]->path);
free(entry_array[position]);
index_entry_free(entry_array[position]);
entry_array[position] = entry;

return GIT_SUCCESS;

cleanup_oom:
free(entry->path);
free(entry);
index_entry_free(entry);
return GIT_ENOMEM;;
}

Expand Down

0 comments on commit b2dd681

Please sign in to comment.