summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-02-21 02:06:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-02-21 02:06:03 (GMT)
commit9fa963663f10a1e35223cb76fe32dd25d5492956 (patch)
tree1ccc139838ac60b768125d3a05bd87f23871e6d1
parentdeafffc6d9ded0ba273c838b4e6787317f4deaa4 (diff)
parent5efde212fc85bd22813d9a4dfca61116adb5d5c0 (diff)
downloadgit-9fa963663f10a1e35223cb76fe32dd25d5492956.zip
git-9fa963663f10a1e35223cb76fe32dd25d5492956.tar.gz
git-9fa963663f10a1e35223cb76fe32dd25d5492956.tar.bz2
Merge branch 'mk/use-size-t-in-zlib' into pu
The wrapper to call into zlib followed our long tradition to use "unsigned long" for sizes of regions in memory, which have been updated to use "size_t". * mk/use-size-t-in-zlib: zlib.c: use size_t for size
-rw-r--r--builtin/pack-objects.c11
-rw-r--r--cache.h10
-rw-r--r--pack-check.c4
-rw-r--r--packfile.c4
-rw-r--r--packfile.h2
-rw-r--r--zlib.c8
6 files changed, 20 insertions, 19 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 89e7ba4..c4c57e0 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -276,12 +276,12 @@ static void copy_pack_data(struct hashfile *f,
off_t len)
{
unsigned char *in;
- unsigned long avail;
+ size_t avail;
while (len) {
in = use_pack(p, w_curs, offset, &avail);
if (avail > len)
- avail = (unsigned long)len;
+ avail = xsize_t(len);
hashwrite(f, in, avail);
offset += avail;
len -= avail;
@@ -1668,8 +1668,8 @@ static void check_object(struct object_entry *entry)
struct pack_window *w_curs = NULL;
const unsigned char *base_ref = NULL;
struct object_entry *base_entry;
- unsigned long used, used_0;
- unsigned long avail;
+ size_t used, used_0;
+ size_t avail;
off_t ofs;
unsigned char *buf, c;
enum object_type type;
@@ -2124,7 +2124,8 @@ unsigned long oe_get_size_slow(struct packing_data *pack,
struct pack_window *w_curs;
unsigned char *buf;
enum object_type type;
- unsigned long used, avail, size;
+ unsigned long used, size;
+ size_t avail;
if (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {
packing_data_lock(&to_pack);
diff --git a/cache.h b/cache.h
index 37c899b..b3fcb60 100644
--- a/cache.h
+++ b/cache.h
@@ -21,10 +21,10 @@
#include <zlib.h>
typedef struct git_zstream {
z_stream z;
- unsigned long avail_in;
- unsigned long avail_out;
- unsigned long total_in;
- unsigned long total_out;
+ size_t avail_in;
+ size_t avail_out;
+ size_t total_in;
+ size_t total_out;
unsigned char *next_in;
unsigned char *next_out;
} git_zstream;
@@ -41,7 +41,7 @@ void git_deflate_end(git_zstream *);
int git_deflate_abort(git_zstream *);
int git_deflate_end_gently(git_zstream *);
int git_deflate(git_zstream *, int flush);
-unsigned long git_deflate_bound(git_zstream *, unsigned long);
+size_t git_deflate_bound(git_zstream *, size_t);
#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
#define DTYPE(de) ((de)->d_type)
diff --git a/pack-check.c b/pack-check.c
index e4ef71c..36a46e4 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -33,7 +33,7 @@ int check_pack_crc(struct packed_git *p, struct pack_window **w_curs,
uint32_t data_crc = crc32(0, NULL, 0);
do {
- unsigned long avail;
+ size_t avail;
void *data = use_pack(p, w_curs, offset, &avail);
if (avail > len)
avail = len;
@@ -69,7 +69,7 @@ static int verify_packfile(struct repository *r,
r->hash_algo->init_fn(&ctx);
do {
- unsigned long remaining;
+ size_t remaining;
unsigned char *in = use_pack(p, w_curs, offset, &remaining);
offset += remaining;
if (!pack_sig_ofs)
diff --git a/packfile.c b/packfile.c
index 99dd1a7..4327eeb 100644
--- a/packfile.c
+++ b/packfile.c
@@ -612,7 +612,7 @@ static int in_window(struct pack_window *win, off_t offset)
unsigned char *use_pack(struct packed_git *p,
struct pack_window **w_cursor,
off_t offset,
- unsigned long *left)
+ size_t *left)
{
struct pack_window *win = *w_cursor;
@@ -1132,7 +1132,7 @@ int unpack_object_header(struct packed_git *p,
unsigned long *sizep)
{
unsigned char *base;
- unsigned long left;
+ size_t left;
unsigned long used;
enum object_type type;
diff --git a/packfile.h b/packfile.h
index ec536a4..0866a46 100644
--- a/packfile.h
+++ b/packfile.h
@@ -87,7 +87,7 @@ int close_pack_fd(struct packed_git *p);
uint32_t get_pack_fanout(struct packed_git *p, uint32_t value);
-unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);
+unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, size_t *);
void close_pack_windows(struct packed_git *);
void close_pack(struct packed_git *);
void close_object_store(struct raw_object_store *o);
diff --git a/zlib.c b/zlib.c
index d594cba..197a1ac 100644
--- a/zlib.c
+++ b/zlib.c
@@ -29,7 +29,7 @@ static const char *zerr_to_string(int status)
*/
/* #define ZLIB_BUF_MAX ((uInt)-1) */
#define ZLIB_BUF_MAX ((uInt) 1024 * 1024 * 1024) /* 1GB */
-static inline uInt zlib_buf_cap(unsigned long len)
+static inline uInt zlib_buf_cap(size_t len)
{
return (ZLIB_BUF_MAX < len) ? ZLIB_BUF_MAX : len;
}
@@ -46,8 +46,8 @@ static void zlib_pre_call(git_zstream *s)
static void zlib_post_call(git_zstream *s)
{
- unsigned long bytes_consumed;
- unsigned long bytes_produced;
+ size_t bytes_consumed;
+ size_t bytes_produced;
bytes_consumed = s->z.next_in - s->next_in;
bytes_produced = s->z.next_out - s->next_out;
@@ -150,7 +150,7 @@ int git_inflate(git_zstream *strm, int flush)
#define deflateBound(c,s) ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
#endif
-unsigned long git_deflate_bound(git_zstream *strm, unsigned long size)
+size_t git_deflate_bound(git_zstream *strm, size_t size)
{
return deflateBound(&strm->z, size);
}