diff --git a/include/git2/index.h b/include/git2/index.h index d34ed0a92..18ab9b858 100644 --- a/include/git2/index.h +++ b/include/git2/index.h @@ -98,14 +98,14 @@ typedef struct git_index_entry { unsigned short flags; unsigned short flags_extended; - const char *path; + char *path; } git_index_entry; /** Representation of an unmerged file entry in the index. */ typedef struct git_index_entry_unmerged { unsigned int mode[3]; git_oid oid[3]; - const char *path; + char *path; } git_index_entry_unmerged; /** diff --git a/src/index.c b/src/index.c index 6390da3d7..bdae26c77 100644 --- a/src/index.c +++ b/src/index.c @@ -227,14 +227,14 @@ void git_index_clear(git_index *index) for (i = 0; i < index->entries.length; ++i) { git_index_entry *e; e = git_vector_get(&index->entries, i); - free((char *)e->path); + free(e->path); free(e); } for (i = 0; i < index->unmerged.length; ++i) { git_index_entry_unmerged *e; e = git_vector_get(&index->unmerged, i); - free((char *)e->path); + free(e->path); free(e); } @@ -391,14 +391,14 @@ 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((char *)entry_array[position]->path); + free(entry_array[position]->path); free(entry_array[position]); entry_array[position] = entry; return GIT_SUCCESS; cleanup_oom: - free((char *)entry->path); + free(entry->path); free(entry); return GIT_ENOMEM;; } @@ -680,7 +680,7 @@ static int read_unmerged(git_index *index, const char *buffer, size_t size) continue; if (size < 20) return git__throw(GIT_ERROR, "Failed to read unmerged entries"); - git_oid_fromraw(&lost->oid[i], (unsigned char *) buffer); + git_oid_fromraw(&lost->oid[i], (const unsigned char *) buffer); size -= 20; buffer += 20; } @@ -715,7 +715,7 @@ static size_t read_entry(git_index_entry *dest, const void *buffer, size_t buffe dest->flags = ntohs(source->flags); if (dest->flags & GIT_IDXENTRY_EXTENDED) { - struct entry_long *source_l = (struct entry_long *)source; + const struct entry_long *source_l = (const struct entry_long *)source; path_ptr = source_l->path; flags_raw = ntohs(source_l->flags_extended);