summaryrefslogtreecommitdiff
path: root/src/indexer.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-05-14 19:12:48 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2014-05-17 01:39:43 +0200
commit0731a5b4db086eefac1a842e37526ef7bdbaa7de (patch)
tree8de449f06fae5e819e750ae7ae0f29cfe33574e6 /src/indexer.c
parentf7310540ae888454f9ab69200cfcd8df07faf957 (diff)
downloadlibgit2-cmn/indexer-mmap.tar.gz
indexer: mmap fixes for Windowscmn/indexer-mmap
Windows has its own ftruncate() called _chsize_s(). p_mkstemp() is changed to use p_open() so we can make sure we open for writing; the addition of exclusive create is a good thing to do regardless, as we want a temporary path for ourselves. Lastly, MSVC doesn't quite know how to add two numbers if one of them is a void pointer, so let's alias it to unsigned char.C
Diffstat (limited to 'src/indexer.c')
-rw-r--r--src/indexer.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/indexer.c b/src/indexer.c
index 11268e018..ebfdffb47 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -429,6 +429,7 @@ static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t
git_file fd = idx->pack->mwf.fd;
long page_size = git__page_size();
git_off_t page_start, page_offset;
+ unsigned char *map_data;
git_map map;
int error;
@@ -439,7 +440,8 @@ static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t
if ((error = p_mmap(&map, page_offset + size, GIT_PROT_WRITE, GIT_MAP_SHARED, fd, page_start)) < 0)
return error;
- memcpy(map.data + page_offset, data, size);
+ map_data = (unsigned char *)map.data;
+ memcpy(map_data + page_offset, data, size);
p_munmap(&map);
return 0;