summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2011-08-08 16:56:28 -0700
committerVicent Marti <tanoku@gmail.com>2011-08-08 16:56:28 -0700
commitf6867e639a963726f381739314ea7a9d181c5aae (patch)
tree29ab8bbd4fbe1532853b2c50b806431354499335 /src
parent09df3f2c0f72dbcf206cc48f508919e03671a946 (diff)
downloadlibgit2-f6867e639a963726f381739314ea7a9d181c5aae.tar.gz
Fix compilation in Windows
Diffstat (limited to 'src')
-rw-r--r--src/indexer.c8
-rw-r--r--src/mwindow.c31
-rw-r--r--src/mwindow.h8
-rw-r--r--src/odb_pack.c1
-rw-r--r--src/refs.c2
5 files changed, 25 insertions, 25 deletions
diff --git a/src/indexer.c b/src/indexer.c
index 7a2b28ae3..fcc0229e3 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -104,8 +104,10 @@ int git_indexer_new(git_indexer **out, const char *packname)
namelen = strlen(packname);
idx->pack = git__malloc(sizeof(struct git_pack_file) + namelen + 1);
- if (idx->pack == NULL)
+ if (idx->pack == NULL) {
+ error = GIT_ENOMEM;
goto cleanup;
+ }
memset(idx->pack, 0x0, sizeof(struct git_pack_file));
memcpy(idx->pack->pack_name, packname, namelen + 1);
@@ -127,7 +129,7 @@ int git_indexer_new(git_indexer **out, const char *packname)
}
idx->pack->mwf.fd = ret;
- idx->pack->mwf.size = idx->st.st_size;
+ idx->pack->mwf.size = (git_off_t)idx->st.st_size;
error = parse_header(idx);
if (error < GIT_SUCCESS) {
@@ -170,7 +172,7 @@ int git_indexer_write(git_indexer *idx)
{
git_mwindow *w = NULL;
int error, namelen;
- unsigned int i, long_offsets, left;
+ unsigned int i, long_offsets = 0, left;
struct git_pack_idx_header hdr;
char filename[GIT_PATH_MAX];
struct entry *entry;
diff --git a/src/mwindow.c b/src/mwindow.c
index 2f7fc7f7d..e9dbfb325 100644
--- a/src/mwindow.c
+++ b/src/mwindow.c
@@ -44,8 +44,10 @@
*/
static git_mwindow_ctl ctl = {
- .window_size = DEFAULT_WINDOW_SIZE,
- .mapped_limit = DEFAULT_MAPPED_LIMIT
+ 0,
+ 0,
+ DEFAULT_WINDOW_SIZE,
+ DEFAULT_MAPPED_LIMIT
};
/*
@@ -87,11 +89,11 @@ void git_mwindow_free_all(git_mwindow_file *mwf)
/*
* Check if a window 'win' contains the address 'offset'
*/
-int git_mwindow_contains(git_mwindow *win, off_t offset)
+int git_mwindow_contains(git_mwindow *win, git_off_t offset)
{
- off_t win_off = win->offset;
+ git_off_t win_off = win->offset;
return win_off <= offset
- && offset <= (off_t)(win_off + win->window_map.len);
+ && offset <= (git_off_t)(win_off + win->window_map.len);
}
/*
@@ -156,10 +158,10 @@ int git_mwindow_close_lru(git_mwindow_file *mwf)
return git__throw(GIT_ERROR, "Failed to close memory window. Couln't find LRU");
}
-static git_mwindow *new_window(git_mwindow_file *mwf, git_file fd, size_t size, off_t offset)
+static git_mwindow *new_window(git_mwindow_file *mwf, git_file fd, git_off_t size, git_off_t offset)
{
size_t walign = ctl.window_size / 2;
- size_t len;
+ git_off_t len;
git_mwindow *w;
w = git__malloc(sizeof(*w));
@@ -170,17 +172,17 @@ static git_mwindow *new_window(git_mwindow_file *mwf, git_file fd, size_t size,
w->offset = (offset / walign) * walign;
len = size - w->offset;
- if (len > ctl.window_size)
- len = ctl.window_size;
+ if (len > (git_off_t)ctl.window_size)
+ len = (git_off_t)ctl.window_size;
- ctl.mapped += len;
+ ctl.mapped += (size_t)len;
while(ctl.mapped_limit < ctl.mapped &&
git_mwindow_close_lru(mwf) == GIT_SUCCESS) {}
/* FIXME: Shouldn't we error out if there's an error in closing lru? */
- if (git_futils_mmap_ro(&w->window_map, fd, w->offset, len) < GIT_SUCCESS)
+ if (git_futils_mmap_ro(&w->window_map, fd, w->offset, (size_t)len) < GIT_SUCCESS)
goto cleanup;
ctl.mmap_calls++;
@@ -204,7 +206,7 @@ cleanup:
* enough space. Don't forget to add it to your list
*/
unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor,
- off_t offset, int extra, unsigned int *left)
+ git_off_t offset, int extra, unsigned int *left)
{
git_mwindow *w = *cursor;
@@ -242,12 +244,9 @@ unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor,
assert(git__is_sizet(offset));
if (left)
- *left = w->window_map.len - offset;
+ *left = (unsigned int)(w->window_map.len - offset);
return (unsigned char *) w->window_map.data + offset;
-
- free(w);
- return NULL;
}
int git_mwindow_file_register(git_mwindow_file *mwf)
diff --git a/src/mwindow.h b/src/mwindow.h
index 6c29307a7..1d4a58453 100644
--- a/src/mwindow.h
+++ b/src/mwindow.h
@@ -33,7 +33,7 @@
typedef struct git_mwindow {
struct git_mwindow *next;
git_map window_map;
- off_t offset;
+ git_off_t offset;
unsigned int last_used;
unsigned int inuse_cnt;
} git_mwindow;
@@ -41,7 +41,7 @@ typedef struct git_mwindow {
typedef struct git_mwindow_file {
git_mwindow *windows;
int fd;
- off_t size;
+ git_off_t size;
} git_mwindow_file;
typedef struct git_mwindow_ctl {
@@ -56,9 +56,9 @@ typedef struct git_mwindow_ctl {
git_vector windowfiles;
} git_mwindow_ctl;
-int git_mwindow_contains(git_mwindow *win, off_t offset);
+int git_mwindow_contains(git_mwindow *win, git_off_t offset);
void git_mwindow_free_all(git_mwindow_file *mwf);
-unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor, off_t offset, int extra, unsigned int *left);
+unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor, git_off_t offset, int extra, unsigned int *left);
void git_mwindow_scan_lru(git_mwindow_file *mwf, git_mwindow **lru_w, git_mwindow **lru_l);
int git_mwindow_file_register(git_mwindow_file *mwf);
void git_mwindow_close(git_mwindow **w_cursor);
diff --git a/src/odb_pack.c b/src/odb_pack.c
index 0d6bb05cc..fc2408e76 100644
--- a/src/odb_pack.c
+++ b/src/odb_pack.c
@@ -179,6 +179,7 @@ static int pack_entry_find_prefix(struct git_pack_entry *e,
GIT_INLINE(void) pack_window_free_all(struct pack_backend *GIT_UNUSED(backend), struct git_pack_file *p)
{
+ GIT_UNUSED_ARG(backend);
git_mwindow_free_all(&p->mwf);
}
diff --git a/src/refs.c b/src/refs.c
index 0468e7590..beb98a780 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -160,8 +160,6 @@ static int reference_read(git_fbuffer *file_content, time_t *mtime, const char *
git_path_join(path, repo_path, ref_name);
return git_futils_readbuffer_updated(file_content, path, mtime, updated);
-
- return GIT_SUCCESS;
}