Permalink
Browse files

Fix compilation in Windows

  • Loading branch information...
1 parent 09df3f2 commit f6867e639a963726f381739314ea7a9d181c5aae @vmg vmg committed Aug 8, 2011
Showing with 912 additions and 32 deletions.
  1. +442 −0 deps/zlib/crc32.c
  2. +441 −0 deps/zlib/crc32.h
  3. +5 −3 src/indexer.c
  4. +15 −16 src/mwindow.c
  5. +4 −4 src/mwindow.h
  6. +1 −0 src/odb_pack.c
  7. +0 −2 src/refs.c
  8. +4 −7 tests/t04-commit.c
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -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;
View
@@ -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 @@ static git_mwindow *new_window(git_mwindow_file *mwf, git_file fd, size_t size,
* 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)
View
@@ -33,15 +33,15 @@
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;
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);
View
@@ -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);
}
View
@@ -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;
}
View
@@ -499,7 +499,7 @@ END_TEST
/* External declaration for testing the buffer parsing method */
-int commit_parse_buffer(git_commit *commit, void *data, size_t len, unsigned int parse_flags);
+int commit_parse_buffer(git_commit *commit, void *data, size_t len);
BEGIN_TEST(parse2, "parse a whole commit buffer")
const int broken_commit_count = sizeof(test_commits_broken) / sizeof(*test_commits_broken);
@@ -519,8 +519,7 @@ BEGIN_TEST(parse2, "parse a whole commit buffer")
must_fail(commit_parse_buffer(
commit,
test_commits_broken[i],
- strlen(test_commits_broken[i]),
- 0x1)
+ strlen(test_commits_broken[i]))
);
git_commit__free(commit);
@@ -536,8 +535,7 @@ BEGIN_TEST(parse2, "parse a whole commit buffer")
must_pass(commit_parse_buffer(
commit,
test_commits_working[i],
- strlen(test_commits_working[i]),
- 0x0)
+ strlen(test_commits_working[i]))
);
git_commit__free(commit);
@@ -549,8 +547,7 @@ BEGIN_TEST(parse2, "parse a whole commit buffer")
must_pass(commit_parse_buffer(
commit,
test_commits_working[i],
- strlen(test_commits_working[i]),
- 0x1)
+ strlen(test_commits_working[i]))
);
git_commit__free(commit);

0 comments on commit f6867e6

Please sign in to comment.