summaryrefslogtreecommitdiff
path: root/src/indexer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/indexer.c')
-rw-r--r--src/indexer.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/indexer.c b/src/indexer.c
index 25c3d0537..93fe9463a 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -427,15 +427,19 @@ static void hash_partially(git_indexer *idx, const uint8_t *data, size_t size)
static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t size)
{
git_file fd = idx->pack->mwf.fd;
- long page_size = git__page_size();
- git_off_t page_start, page_offset;
+ size_t page_size;
+ size_t page_offset;
+ git_off_t page_start;
unsigned char *map_data;
git_map map;
int error;
+ if ((error = git__page_size(&page_size)) < 0)
+ return error;
+
/* the offset needs to be at the beginning of the a page boundary */
- page_start = (offset / page_size) * page_size;
- page_offset = offset - page_start;
+ page_offset = offset % page_size;
+ page_start = offset - page_offset;
if ((error = p_mmap(&map, page_offset + size, GIT_PROT_WRITE, GIT_MAP_SHARED, fd, page_start)) < 0)
return error;