8000 internal: use off64_t instead of git_off_t · libgit2/libgit2@f48d720 · GitHub
[go: up one dir, main page]

Skip to content

Commit f48d720

Browse files
committed
internal: use off64_t instead of git_off_t
Prefer `off64_t` internally.
1 parent 068c2e1 commit f48d720

File tree

13 files changed

+78
-78
lines changed

13 files changed

+78
-78
lines changed

src/indexer.c

Lines changed: 19 additions & 19 deletions
57AE
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ struct git_indexer {
4747
struct git_pack_header hdr;
4848
struct git_pack_file *pack;
4949
unsigned int mode;
50-
git_off_t off;
51-
git_off_t entry_start;
50+
off64_t off;
51+
off64_t entry_start;
5252
git_object_t entry_type;
5353
git_buf entry_data;
5454
git_packfile_stream stream;
@@ -75,7 +75,7 @@ struct git_indexer {
7575
};
7676

7777
struct delta_info {
78-
git_off_t delta_off;
78+
off64_t delta_off;
7979
};
8080

8181
const git_oid *git_indexer_hash(const git_indexer *idx)
@@ -220,7 +220,7 @@ static int store_delta(git_indexer *idx)
220220
return 0;
221221
}
222222

223-
static int hash_header(git_hash_ctx *ctx, git_off_t len, git_object_t type)
223+
static int hash_header(git_hash_ctx *ctx, off64_t len, git_object_t type)
224224
{
225225
char buffer[64];
226226
size_t hdrlen;
@@ -265,7 +265,7 @@ static int advance_delta_offset(git_indexer *idx, git_object_t type)
265265
if (type == GIT_OBJECT_REF_DELTA) {
266266
idx->off += GIT_OID_RAWSZ;
267267
} else {
268-
git_off_t base_off = get_delta_base(idx->pack, &w, &idx->off, type, idx->entry_start);
268+
off64_t base_off = get_delta_base(idx->pack, &w, &idx->off, type, idx->entry_start);
269269
git_mwindow_close(&w);
270270
if (base_off < 0)
271271
return (int)base_off;
@@ -291,7 +291,7 @@ static int read_object_stream(git_indexer *idx, git_packfile_stream *stream)
291291
return 0;
292292
}
293293

294-
static int crc_object(uint32_t *crc_out, git_mwindow_file *mwf, git_off_t start, git_off_t size)
294+
static int crc_object(uint32_t *crc_out, git_mwindow_file *mwf, off64_t start, off64_t size)
295295
{
296296
void *ptr;
297297
uint32_t crc;
@@ -414,9 +414,9 @@ static int store_object(git_indexer *idx)
414414
int i, error;
415415
git_oid oid;
416416
struct entry *entry;
417-
git_off_t entry_size;
417+
off64_t entry_size;
418418
struct git_pack_entry *pentry;
419-
git_off_t entry_start = idx->entry_start;
419+
off64_t entry_start = idx->entry_start;
420420

421421
entry = git__calloc(1, sizeof(*entry));
422422
GIT_ERROR_CHECK_ALLOC(entry);
@@ -485,7 +485,7 @@ GIT_INLINE(bool) has_entry(git_indexer *idx, git_oid *id)
485485
return git_oidmap_exists(idx->pack->idx_cache, id);
486486
}
487487

488-
static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_entry *pentry, git_off_t entry_start)
488+
static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_entry *pentry, off64_t entry_start)
489489
{
490490
int i;
491491

@@ -515,7 +515,7 @@ static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_ent
515515
return 0;
516516
}
517517

518-
static int hash_and_save(git_indexer *idx, git_rawobj *obj, git_off_t entry_start)
518+
static int hash_and_save(git_indexer *idx, git_rawobj *obj, off64_t entry_start)
519519
{
520520
git_oid oid;
521521
size_t entry_size;
@@ -596,12 +596,12 @@ static void hash_partially(git_indexer *idx, const uint8_t *data, size_t size)
596596
idx->inbuf_len += size - to_expell;
597597
}
598598

599-
static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t size)
599+
static int write_at(git_indexer *idx, const void *data, off64_t offset, size_t size)
600600
{
601601
git_file fd = idx->pack->mwf.fd;
602602
size_t mmap_alignment;
603603
size_t page_offset;
604-
git_off_t page_start;
604+
off64_t page_start;
605605
unsigned char *map_data;
606606
git_map map;
607607
int error;
@@ -627,11 +627,11 @@ static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t
627627

628628
static int append_to_pack(git_indexer *idx, const void *data, size_t size)
629629
{
630-
git_off_t new_size;
630+
off64_t new_size;
631631
size_t mmap_alignment;
632632
size_t page_offset;
633-
git_off_t page_start;
634-
git_off_t current_size = idx->pack->mwf.size;
633+
off64_t page_start;
634+
off64_t current_size = idx->pack->mwf.size;
635635
int fd = idx->pack->mwf.fd;
636636
int error;
637637

@@ -661,7 +661,7 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size)
661661
static int read_stream_object(git_indexer *idx, git_indexer_progress *stats)
662662
{
663663
git_packfile_stream *stream = &idx->stream;
664-
git_off_t entry_start = idx->off;
664+
off64_t entry_start = idx->off;
665665
size_t entry_size;
666666
git_object_t type;
667667
git_mwindow *w = NULL;
@@ -865,7 +865,7 @@ static int inject_object(git_indexer *idx, git_oid *id)
865865
git_oid foo = {{0}};
866866
unsigned char hdr[64];
867867
git_buf buf = GIT_BUF_INIT;
868-
git_off_t entry_start;
868+
off64_t entry_start;
869869
const void *data;
870870
size_t len, hdr_len;
871871
int error;
@@ -939,7 +939,7 @@ static int fix_thin_pack(git_indexer *idx, git_indexer_progress *stats)
939939
size_t size;
940940
git_object_t type;
941941
git_mwindow *w = NULL;
942-
git_off_t curpos = 0;
942+
off64_t curpos = 0;
943943
unsigned char *base_info;
944944
unsigned int left = 0;
945945
git_oid base;
@@ -1054,7 +1054,7 @@ static int update_header_and_rehash(git_indexer *idx, git_indexer_progress *stat
10541054< 10000 /code>
{
10551055
void *ptr;
10561056
size_t chunk = 1024*1024;
1057-
git_off_t hashed = 0;
1057+
off64_t hashed = 0;
10581058
git_mwindow *w = NULL;
10591059
git_mwindow_file *mwf;
10601060
unsigned int left;

src/mwindow.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ void git_mwindow_free_all_locked(git_mwindow_file *mwf)
167167
/*
168168
* Check if a window 'win' contains the address 'offset'
169169
*/
170-
int git_mwindow_contains(git_mwindow *win, git_off_t offset)
170+
int git_mwindow_contains(git_mwindow *win, off64_t offset)
171171
{
172-
git_off_t win_off = win->offset;
172+
off64_t win_off = win->offset;
173173
return win_off <= offset
174-
&& offset <= (git_off_t)(win_off + win->window_map.len);
174+
&& offset <= (off64_t)(win_off + win->window_map.len);
175175
}
176176

177177
/*
@@ -246,12 +246,12 @@ static int git_mwindow_close_lru(git_mwindow_file *mwf)
246246
static git_mwindow *new_window(
247247
git_mwindow_file *mwf,
248248
git_file fd,
249-
git_off_t size,
250-
git_off_t offset)
249+
off64_t size,
250+
off64_t offset)
251251
{
252252
git_mwindow_ctl *ctl = &mem_ctl;
253253
size_t walign = git_mwindow__window_size / 2;
254-
git_off_t len;
254+
off64_t len;
255255
git_mwindow *w;
256256

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

265265
len = size - w->offset;
266-
if (len > (git_off_t)git_mwindow__window_size)
267-
len = (git_off_t)git_mwindow__window_size;
266+
if (len > (off64_t)git_mwindow__window_size)
267+
len = (off64_t)git_mwindow__window_size;
268268

269269
ctl->mapped += (size_t)len;
270270

@@ -311,7 +311,7 @@ static git_mwindow *new_window(
311311
unsigned char *git_mwindow_open(
312312
git_mwindow_file *mwf,
313313
git_mwindow **cursor,
314-
git_off_t offset,
314+
off64_t offset,
315315
size_t extra,
316316
unsigned int *left)
317317
{

src/mwindow.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
typedef struct git_mwindow {
1717
struct git_mwindow *next;
1818
git_map window_map;
19-
git_off_t offset;
19+
off64_t offset;
2020
size_t last_used;
2121
size_t inuse_cnt;
2222
} git_mwindow;
2323

2424
typedef struct git_mwindow_file {
2525
git_mwindow *windows;
2626
int fd;
27-
git_off_t size;
27+
off64_t size;
2828
} git_mwindow_file;
2929

3030
typedef struct git_mwindow_ctl {
@@ -37,10 +37,10 @@ typedef struct git_mwindow_ctl {
3737
git_vector windowfiles;
3838
} git_mwindow_ctl;
3939

40-
int git_mwindow_contains(git_mwindow *win, git_off_t offset);
40+
int git_mwindow_contains(git_mwindow *win, off64_t offset);
4141
void git_mwindow_free_all(git_mwindow_file *mwf); /* locks */
4242
void git_mwindow_free_all_locked(git_mwindow_file *mwf); /* run under lock */
43-
unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor, git_off_t offset, size_t extra, unsigned int *left);
43+
unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor, off64_t offset, size_t extra, unsigned int *left);
4444
int git_mwindow_file_register(git_mwindow_file *mwf);
4545
void git_mwindow_file_deregister(git_mwindow_file *mwf);
4646
void git_mwindow_close(git_mwindow **w_cursor);

src/pack-objects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
typedef struct git_pobject {
3131
git_oid id;
3232
git_object_t type;
33-
git_off_t offset;
33+
off64_t offset;
3434

3535
size_t size;
3636

0 commit comments

Comments
 (0)
0