summaryrefslogtreecommitdiff
path: root/src/indexer.c
diff options
context:
space:
mode:
authorRussell Belfer <arrbee@arrbee.com>2012-03-12 22:55:40 -0700
committerRussell Belfer <arrbee@arrbee.com>2012-03-12 22:55:40 -0700
commite1de726c15937a8dbf81d12ef0c872cf6576ebd0 (patch)
tree84b437dd23e8250b0a4f983875fb3849569ad63a /src/indexer.c
parentdda708e78f3c3f43d814d46c29ab9f2b9d47ed5c (diff)
downloadlibgit2-e1de726c15937a8dbf81d12ef0c872cf6576ebd0.tar.gz
Migrate ODB files to new error handling
This migrates odb.c, odb_loose.c, odb_pack.c and pack.c to the new style of error handling. Also got the unix and win32 versions of map.c. There are some minor changes to other files but no others were completely converted. This also contains an update to filebuf so that a zeroed out filebuf will not think that the fd (== 0) is actually open (and inadvertently call close() on fd 0 if cleaned up). Lastly, this was built and tested on win32 and contains a bunch of fixes for the win32 build which was pretty broken.
Diffstat (limited to 'src/indexer.c')
-rw-r--r--src/indexer.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/indexer.c b/src/indexer.c
index dd7c71962..da6495f90 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -307,7 +307,7 @@ cleanup:
int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
{
git_mwindow_file *mwf;
- off_t off = sizeof(struct git_pack_header);
+ git_off_t off = sizeof(struct git_pack_header);
int error;
struct entry *entry;
unsigned int left, processed;
@@ -328,18 +328,18 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
struct git_pack_entry *pentry;
git_mwindow *w = NULL;
int i;
- off_t entry_start = off;
+ git_off_t entry_start = off;
void *packed;
size_t entry_size;
- entry = git__malloc(sizeof(struct entry));
- memset(entry, 0x0, sizeof(struct entry));
+ entry = git__calloc(1, sizeof(*entry));
+ GITERR_CHECK_ALLOC(entry);
if (off > UINT31_MAX) {
entry->offset = UINT32_MAX;
entry->offset_long = off;
} else {
- entry->offset = off;
+ entry->offset = (uint32_t)off;
}
error = git_packfile_unpack(&obj, idx->pack, &off);
@@ -369,7 +369,7 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
git_oid_cpy(&entry->oid, &oid);
entry->crc = crc32(0L, Z_NULL, 0);
- entry_size = off - entry_start;
+ entry_size = (size_t)(off - entry_start);
packed = git_mwindow_open(mwf, &w, entry_start, entry_size, &left);
if (packed == NULL) {
error = git__rethrow(error, "Failed to open window to read packed data");