summaryrefslogtreecommitdiff
path: root/src/indexer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/indexer.c')
-rw-r--r--src/indexer.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/indexer.c b/src/indexer.c
index 20337d552..4a4ed325a 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -461,10 +461,10 @@ int git_indexer_stream_finalize(git_indexer_stream *idx, git_transfer_progress *
struct entry *entry;
void *packfile_hash;
git_oid file_hash;
- git_hash_ctx *ctx;
+ git_hash_ctx ctx;
- ctx = git_hash_ctx_new();
- GITERR_CHECK_ALLOC(ctx);
+ if (git_hash_ctx_init(&ctx) < 0)
+ return -1;
/* Test for this before resolve_deltas(), as it plays with idx->off */
if (idx->off < idx->pack->mwf.size - GIT_OID_RAWSZ) {
@@ -506,9 +506,9 @@ int git_indexer_stream_finalize(git_indexer_stream *idx, git_transfer_progress *
/* Write out the object names (SHA-1 hashes) */
git_vector_foreach(&idx->objects, i, entry) {
git_filebuf_write(&idx->index_file, &entry->oid, sizeof(git_oid));
- git_hash_update(ctx, &entry->oid, GIT_OID_RAWSZ);
+ git_hash_update(&ctx, &entry->oid, GIT_OID_RAWSZ);
}
- git_hash_final(&idx->hash, ctx);
+ git_hash_final(&idx->hash, &ctx);
/* Write out the CRC32 values */
git_vector_foreach(&idx->objects, i, entry) {
@@ -583,7 +583,7 @@ on_error:
p_close(idx->pack->mwf.fd);
git_filebuf_cleanup(&idx->index_file);
git_buf_free(&filename);
- git_hash_ctx_free(ctx);
+ git_hash_ctx_cleanup(&ctx);
return -1;
}
@@ -684,10 +684,10 @@ int git_indexer_write(git_indexer *idx)
struct entry *entry;
void *packfile_hash;
git_oid file_hash;
- git_hash_ctx *ctx;
+ git_hash_ctx ctx;
- ctx = git_hash_ctx_new();
- GITERR_CHECK_ALLOC(ctx);
+ if (git_hash_ctx_init(&ctx) < 0)
+ return -1;
git_vector_sort(&idx->objects);
@@ -719,11 +719,11 @@ int git_indexer_write(git_indexer *idx)
/* Write out the object names (SHA-1 hashes) */
git_vector_foreach(&idx->objects, i, entry) {
if ((error = git_filebuf_write(&idx->file, &entry->oid, sizeof(git_oid))) < 0 ||
- (error = git_hash_update(ctx, &entry->oid, GIT_OID_RAWSZ)) < 0)
+ (error = git_hash_update(&ctx, &entry->oid, GIT_OID_RAWSZ)) < 0)
goto cleanup;
}
- if ((error = git_hash_final(&idx->hash, ctx)) < 0)
+ if ((error = git_hash_final(&idx->hash, &ctx)) < 0)
goto cleanup;
/* Write out the CRC32 values */
@@ -802,7 +802,7 @@ cleanup:
if (error < 0)
git_filebuf_cleanup(&idx->file);
git_buf_free(&filename);
- git_hash_ctx_free(ctx);
+ git_hash_ctx_cleanup(&ctx);
return error;
}