8000 Move `git_off_t` to `git_object_size_t` by ethomson · Pull Request #5123 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content

Move git_off_t to git_object_size_t #5123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
internal: use off64_t instead of git_off_t
Prefer `off64_t` internally.
  • Loading branch information
ethomson committed Nov 25, 2019
commit 6460e8abcfda7692af9bd267bddf6e11a78f8130
38 changes: 19 additions & 19 deletions src/indexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ struct git_indexer {
struct git_pack_header hdr;
struct git_pack_file *pack;
unsigned int mode;
git_off_t off;
git_off_t entry_start;
off64_t off;
off64_t entry_start;
git_object_t entry_type;
git_buf entry_data;
git_packfile_stream stream;
Expand All @@ -75,7 +75,7 @@ struct git_indexer {
};

struct delta_info {
git_off_t delta_off;
off64_t delta_off;
};

const git_oid *git_indexer_hash(const git_indexer *idx)
Expand Down Expand Up @@ -220,7 +220,7 @@ static int store_delta(git_indexer *idx)
return 0;
}

static int hash_header(git_hash_ctx *ctx, git_off_t len, git_object_t type)
static int hash_header(git_hash_ctx *ctx, off64_t len, git_object_t type)
{
char buffer[64];
size_t hdrlen;
Expand Down Expand Up @@ -265,7 +265,7 @@ static int advance_delta_offset(git_indexer *idx, git_object_t type)
if (type == GIT_OBJECT_REF_DELTA) {
idx->off += GIT_OID_RAWSZ;
} else {
git_off_t base_off = get_delta_base(idx->pack, &w, &idx->off, type, idx->entry_start);
off64_t base_off = get_delta_base(idx->pack, &w, &idx->off, type, idx->entry_start);
git_mwindow_close(&w);
if (base_off < 0)
return (int)base_off;
Expand All @@ -291,7 +291,7 @@ static int read_object_stream(git_indexer *idx, git_packfile_stream *stream)
return 0;
}

static int crc_object(uint32_t *crc_out, git_mwindow_file *mwf, git_off_t start, git_off_t size)
static int crc_object(uint32_t *crc_out, git_mwindow_file *mwf, off64_t start, off64_t size)
{
void *ptr;
uint32_t crc;
Expand Down Expand Up @@ -414,9 +414,9 @@ static int store_object(git_indexer *idx)
int i, error;
git_oid oid;
struct entry *entry;
git_off_t entry_size;
off64_t entry_size;
struct git_pack_entry *pentry;
git_off_t entry_start = idx->entry_start;
off64_t entry_start = idx->entry_start;

entry = git__calloc(1, sizeof(*entry));
GIT_ERROR_CHECK_ALLOC(entry);
Expand Down Expand Up @@ -485,7 +485,7 @@ GIT_INLINE(bool) has_entry(git_indexer *idx, git_oid *id)
return git_oidmap_exists(idx->pack->idx_cache, id);
}

static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_entry *pentry, git_off_t entry_start)
static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_entry *pentry, off64_t entry_start)
{
int i;

Expand Down Expand Up @@ -515,7 +515,7 @@ static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_ent
return 0;
}

static int hash_and_save(git_indexer *idx, git_rawobj *obj, git_off_t entry_start)
static int hash_and_save(git_indexer *idx, git_rawobj *obj, off64_t entry_start)
{
git_oid oid;
size_t entry_size;
Expand Down Expand Up @@ -596,12 +596,12 @@ static void hash_partially(git_indexer *idx, const uint8_t *data, size_t size)
idx->inbuf_len += size - to_expell;
}

static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t size)
static int write_at(git_indexer *idx, const void *data, off64_t offset, size_t size)
{
git_file fd = idx->pack->mwf.fd;
size_t mmap_alignment;
size_t page_offset;
git_off_t page_start;
off64_t page_start;
unsigned char *map_data;
git_map map;
int error;
Expand All @@ -627,11 +627,11 @@ static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t

static int append_to_pack(git_indexer *idx, const void *data, size_t size)
{
git_off_t new_size;
off64_t new_size;
size_t mmap_alignment;
size_t page_offset;
git_off_t page_start;
git_off_t current_size = idx->pack->mwf.size;
off64_t page_start;
off64_t current_size = idx->pack->mwf.size;
int fd = idx->pack->mwf.fd;
int error;

Expand Down Expand Up @@ -661,7 +661,7 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size)
static int read_stream_object(git_indexer *idx, git_indexer_progress *stats)
{
git_packfile_stream *stream = &idx->stream;
git_off_t entry_start = idx->off;
off64_t entry_start = idx->off;
size_t entry_size;
git_object_t type;
git_mwindow *w = NULL;
Expand Down Expand Up @@ -865,7 +865,7 @@ static int inject_object(git_indexer *idx, git_oid *id)
git_oid foo = {{0}};
unsigned char hdr[64];
git_buf buf = GIT_BUF_INIT;
git_off_t entry_start;
off64_t entry_start;
const void *data;
size_t len, hdr_len;
int error;
Expand Down Expand Up @@ -939,7 +939,7 @@ static int fix_thin_pack(git_indexer *idx, git_indexer_progress *stats)
size_t size;
git_object_t type;
git_mwindow *w = NULL;
git_off_t curpos = 0;
off64_t curpos = 0;
unsigned char *base_info;
unsigned int left = 0;
git_oid base;
Expand Down Expand Up @@ -1054,7 +1054,7 @@ static int update_header_and_rehash(git_indexer *idx, git_indexer_progress *stat
{
void *ptr;
size_t chunk = 1024*1024;
git_off_t hashed = 0;
off64_t hashed = 0;
git_mwindow *w = NULL;
git_mwindow_file *mwf;
unsigned int left;
Expand Down
18 changes: 9 additions & 9 deletions src/mwindow.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ void git_mwindow_free_all_locked(git_mwindow_file *mwf)
/*
* Check if a window 'win' contains the address 'offset'
*/
int git_mwindow_contains(git_mwindow *win, git_off_t offset)
int git_mwindow_contains(git_mwindow *win, off64_t offset)
{
git_off_t win_off = win->offset;
off64_t win_off = win->offset;
return win_off <= offset
&& offset <= (git_off_t)(win_off + win->window_map.len);
&& offset <= (off64_t)(win_off + win->window_map.len);
}

/*
Expand Down Expand Up @@ -246,12 +246,12 @@ static int git_mwindow_close_lru(git_mwindow_file *mwf)
static git_mwindow *new_window(
git_mwindow_file *mwf,
git_file fd,
git_off_t size,
git_off_t offset)
off64_t size,
off64_t offset)
{
git_mwindow_ctl *ctl = &mem_ctl;
size_t walign = git_mwindow__window_size / 2;
git_off_t len;
off64_t len;
git_mwindow *w;

w = git__malloc(sizeof(*w));
Expand All @@ -263,8 +263,8 @@ static git_mwindow *new_window(
w->offset = (offset / walign) * walign;

len = size - w->offset;
if (len > (git_off_t)git_mwindow__window_size)
len = (git_off_t)git_mwindow__window_size;
if (len > (off64_t)git_mwindow__window_size)
len = (off64_t)git_mwindow__window_size;

ctl->mapped += (size_t)len;

Expand Down Expand Up @@ -311,7 +311,7 @@ static git_mwindow *new_window(
unsigned char *git_mwindow_open(
git_mwindow_file *mwf,
git_mwindow **cursor,
git_off_t offset,
off64_t offset,
size_t extra,
unsigned int *left)
{
Expand Down
8 changes: 4 additions & 4 deletions src/mwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
typedef struct git_mwindow {
struct git_mwindow *next;
git_map window_map;
git_off_t offset;
off64_t offset;
size_t last_used;
size_t inuse_cnt;
} git_mwindow;

typedef struct git_mwindow_file {
git_mwindow *windows;
int fd;
git_off_t size;
off64_t size;
} git_mwindow_file;

typedef struct git_mwindow_ctl {
Expand All @@ -37,10 +37,10 @@ typedef struct git_mwindow_ctl {
git_vector windowfiles;
} git_mwindow_ctl;

int git_mwindow_contains(git_mwindow *win, git_off_t offset);
int git_mwindow_contains(git_mwindow *win, off64_t offset);
void git_mwindow_free_all(git_mwindow_file *mwf); /* locks */
void git_mwindow_free_all_locked(git_mwindow_file *mwf); /* run under lock */
unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor, git_off_t offset, size_t extra, unsigned int *left);
unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor, off64_t offset, size_t extra, unsigned int *left);
int git_mwindow_file_register(git_mwindow_file *mwf);
void git_mwindow_file_deregister(git_mwindow_file *mwf);
void git_mwindow_close(git_mwindow **w_cursor);
Expand Down
2 changes: 1 addition & 1 deletion src/pack-objects.h
Original file line number Diff line number D 65C0 iff line change
Expand Up @@ -30,7 +30,7 @@
typedef struct git_pobject {
git_oid id;
git_object_t type;
git_off_t offset;
off64_t offset;

size_t size;

Expand Down
Loading
0