{"thread":{"id":"49862","subject":"[PATCH/RFC v2 1/1] Use size_t instead of 'unsigned long' for data in memory","startedAt":"2018-11-20T05:05:09Z","lastAt":"2018-11-20T05:16:52Z","messageCount":2,"participants":["tboegi@web.de","Torsten Bögershausen"],"isPatch":true,"patchVersion":2,"patchTotal":1},"messages":[{"id":"363696","messageId":"20181120050454.16673-1-tboegi@web.de","threadId":"49862","inReplyTo":null,"subject":"[PATCH/RFC v2 1/1] Use size_t instead of 'unsigned long' for data in memory","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2018-11-20T05:04:54Z","receivedAt":"2018-11-20T05:05:09Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nCurrently the length of data which is stored in memory is stored\nin \"unsigned long\" at many places in the code base.\nThis is OK when both \"unsigned long\" and size_t are 32 bits,\n(and is OK when both are 64 bits).\nOn a 64 bit Windows system am \"unsigned long\" is 32 bit, and\nthat may be too short to measure the size of objects in memory,\na size_t is the natural choice.\n\nImprove the code base in \"small steps\", as small as possible.\nThe smallest step seems to be much bigger than expected.\nSee this code-snippet from convert.c:\n\n        const char *ret;\n\tunsigned long sz;\n\tvoid *data = read_blob_data_from_index(istate, path, &sz);\n\tret = gather_convert_stats_ascii(data, sz);\n\nThe corrected version looks like this:\n        const char *ret;\n\tsize_t sz;\n\tvoid *data = read_blob_data_from_index(istate, path, &sz);\n\tret = gather_convert_stats_ascii(data, sz);\n\nHowever, when the Git code base is compiled with a compiler that\ncomplains that \"unsigned long\" is different from size_t, we end\nup in this huge patch, before the code base cleanly compiles.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n\nThanks for all the comments on V1.\nChanges since V1:\n- Make the motivation somewhat clearer in the commit message\n- Rebase to the November 19 pu\n\nWhat we really need for this patch to fly are this branches:\nmk/use-size-t-in-zlib\ntb/print-size-t-with-uintmax-format\n\nAnd then it is rebased on top of all cooking stuff, too many branches\nto be mentioned here.\n\nIt may be usefull to examine all \"unsigned long\" which are left after\nthis patch and turn them into (what ? unsigned int? size_t? uint32_t ?).\nAnd once they are settled, re-do this patch with help of a coccinelle script.\nI don't know.\nI probably will rebase it until Junio says stop or someone else comes with\na better solution.\n\napply.c                  | 14 ++++-----\n archive-tar.c            | 18 +++++------\n archive-zip.c            |  2 +-\n archive.c                |  2 +-\n archive.h                |  2 +-\n bisect.c                 |  2 +-\n blame.c                  |  6 ++--\n blame.h                  |  2 +-\n builtin/cat-file.c       | 10 +++---\n builtin/difftool.c       |  2 +-\n builtin/fast-export.c    |  6 ++--\n builtin/fmt-merge-msg.c  |  3 +-\n builtin/fsck.c           |  6 ++--\n builtin/grep.c           |  8 ++---\n builtin/index-pack.c     | 27 ++++++++--------\n builtin/log.c            |  4 +--\n builtin/ls-tree.c        |  2 +-\n builtin/merge-tree.c     |  6 ++--\n builtin/mktag.c          |  4 +--\n builtin/notes.c          |  6 ++--\n builtin/pack-objects.c   | 56 +++++++++++++++++-----------------\n builtin/reflog.c         |  2 +-\n builtin/replace.c        |  2 +-\n builtin/tag.c            |  4 +--\n builtin/unpack-file.c    |  2 +-\n builtin/unpack-objects.c | 35 ++++++++++-----------\n builtin/verify-commit.c  |  4 +--\n bundle.c                 |  2 +-\n cache.h                  | 10 +++---\n combine-diff.c           | 11 ++++---\n commit.c                 | 22 +++++++-------\n commit.h                 | 10 +++---\n config.c                 |  2 +-\n convert.c                | 18 +++++------\n delta.h                  | 20 ++++++------\n diff-delta.c             |  4 +--\n diff.c                   | 30 +++++++++---------\n diff.h                   |  2 +-\n diffcore-pickaxe.c       |  4 +--\n diffcore.h               |  2 +-\n dir.c                    |  6 ++--\n dir.h                    |  2 +-\n entry.c                  |  4 +--\n fast-import.c            | 26 ++++++++--------\n fsck.c                   | 12 ++++----\n fsck.h                   |  2 +-\n fuzz-pack-headers.c      |  4 +--\n grep.h                   |  2 +-\n http-push.c              |  2 +-\n list-objects-filter.c    |  2 +-\n mailmap.c                |  2 +-\n match-trees.c            |  4 +--\n merge-blobs.c            |  6 ++--\n merge-blobs.h            |  2 +-\n merge-recursive.c        |  4 +--\n notes-cache.c            |  2 +-\n notes-merge.c            |  4 +--\n notes.c                  |  6 ++--\n object-store.h           | 20 ++++++------\n object.c                 |  4 +--\n object.h                 |  2 +-\n pack-check.c             |  2 +-\n pack-objects.h           | 14 ++++-----\n pack.h                   |  2 +-\n packfile.c               | 40 ++++++++++++------------\n packfile.h               |  8 ++---\n patch-delta.c            |  8 ++---\n range-diff.c             |  2 +-\n read-cache.c             | 48 ++++++++++++++---------------\n ref-filter.c             | 30 +++++++++---------\n remote-testsvn.c         |  4 +--\n rerere.c                 |  2 +-\n sha1-file.c              | 66 ++++++++++++++++++++--------------------\n sha1dc_git.c             |  2 +-\n sha1dc_git.h             |  2 +-\n streaming.c              | 12 ++++----\n streaming.h              |  2 +-\n submodule-config.c       |  2 +-\n t/helper/test-delta.c    |  2 +-\n tag.c                    |  6 ++--\n tag.h                    |  2 +-\n tree-walk.c              | 14 ++++-----\n tree.c                   |  2 +-\n xdiff-interface.c        |  4 +--\n xdiff-interface.h        |  4 +--\n 85 files changed, 388 insertions(+), 384 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex f814a92660..890f36dc74 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3096,7 +3096,7 @@ static int apply_binary_fragment(struct apply_state *state,\n \t\t\t\t struct patch *patch)\n {\n \tstruct fragment *fragment = patch->fragments;\n-\tunsigned long len;\n+\tsize_t len;\n \tvoid *dst;\n \n \tif (!fragment)\n@@ -3186,7 +3186,7 @@ static int apply_binary(struct apply_state *state,\n \tif (repo_has_sha1_file(the_repository, oid.hash)) {\n \t\t/* We already have the postimage */\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *result;\n \n \t\tresult = repo_read_object_file(the_repository, &oid, &type,\n@@ -3249,7 +3249,7 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns\n \t\tstrbuf_addf(buf, \"Subproject commit %s\\n\", oid_to_hex(oid));\n \t} else {\n \t\tenum object_type type;\n-\t\tunsigned long sz;\n+\t\tsize_t sz;\n \t\tchar *result;\n \n \t\tresult = repo_read_object_file(the_repository, oid, &type,\n@@ -4279,7 +4279,7 @@ static int add_index_file(struct apply_state *state,\n \t\t\t  const char *path,\n \t\t\t  unsigned mode,\n \t\t\t  void *buf,\n-\t\t\t  unsigned long size)\n+\t\t\t  size_t size)\n {\n \tstruct stat st;\n \tstruct cache_entry *ce;\n@@ -4333,7 +4333,7 @@ static int add_index_file(struct apply_state *state,\n  */\n static int try_create_file(struct apply_state *state, const char *path,\n \t\t\t   unsigned int mode, const char *buf,\n-\t\t\t   unsigned long size)\n+\t\t\t   size_t size)\n {\n \tint fd, res;\n \tstruct strbuf nbuf = STRBUF_INIT;\n@@ -4384,7 +4384,7 @@ static int create_one_file(struct apply_state *state,\n \t\t\t   char *path,\n \t\t\t   unsigned mode,\n \t\t\t   const char *buf,\n-\t\t\t   unsigned long size)\n+\t\t\t   size_t size)\n {\n \tint res;\n \n@@ -4476,7 +4476,7 @@ static int create_file(struct apply_state *state, struct patch *patch)\n {\n \tchar *path = patch->new_name;\n \tunsigned mode = patch->new_mode;\n-\tunsigned long size = patch->resultsize;\n+\tsize_t size = patch->resultsize;\n \tchar *buf = patch->result;\n \n \tif (!mode)\ndiff --git a/archive-tar.c b/archive-tar.c\nindex a58e1a8ebf..cea52dfc0a 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -13,7 +13,7 @@\n #define BLOCKSIZE\t(RECORDSIZE * 20)\n \n static char block[BLOCKSIZE];\n-static unsigned long offset;\n+static size_t offset;\n \n static int tar_umask = 002;\n \n@@ -51,12 +51,12 @@ static void write_if_needed(void)\n  * queues up writes, so that all our write(2) calls write exactly one\n  * full block; pads writes to RECORDSIZE\n  */\n-static void do_write_blocked(const void *data, unsigned long size)\n+static void do_write_blocked(const void *data, size_t size)\n {\n \tconst char *buf = data;\n \n \tif (offset) {\n-\t\tunsigned long chunk = BLOCKSIZE - offset;\n+\t\tsize_t chunk = BLOCKSIZE - offset;\n \t\tif (size < chunk)\n \t\t\tchunk = size;\n \t\tmemcpy(block + offset, buf, chunk);\n@@ -78,7 +78,7 @@ static void do_write_blocked(const void *data, unsigned long size)\n \n static void finish_record(void)\n {\n-\tunsigned long tail;\n+\tsize_t tail;\n \ttail = offset % RECORDSIZE;\n \tif (tail)  {\n \t\tmemset(block + offset, 0, RECORDSIZE - tail);\n@@ -87,7 +87,7 @@ static void finish_record(void)\n \twrite_if_needed();\n }\n \n-static void write_blocked(const void *data, unsigned long size)\n+static void write_blocked(const void *data, size_t size)\n {\n \tdo_write_blocked(data, size);\n \tfinish_record();\n@@ -116,7 +116,7 @@ static int stream_blocked(const struct object_id *oid)\n {\n \tstruct git_istream *st;\n \tenum object_type type;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tchar buf[BLOCKSIZE];\n \tssize_t readlen;\n \n@@ -199,7 +199,7 @@ static size_t get_path_prefix(const char *path, size_t pathlen, size_t maxlen)\n \n static void prepare_header(struct archiver_args *args,\n \t\t\t   struct ustar_header *header,\n-\t\t\t   unsigned int mode, unsigned long size)\n+\t\t\t   unsigned int mode, size_t size)\n {\n \txsnprintf(header->mode, sizeof(header->mode), \"%07o\", mode & 07777);\n \txsnprintf(header->size, sizeof(header->size), \"%011\"PRIoMAX , S_ISREG(mode) ? (uintmax_t)size : (uintmax_t)0);\n@@ -220,7 +220,7 @@ static void prepare_header(struct archiver_args *args,\n \n static void write_extended_header(struct archiver_args *args,\n \t\t\t\t  const struct object_id *oid,\n-\t\t\t\t  const void *buffer, unsigned long size)\n+\t\t\t\t  const void *buffer, size_t size)\n {\n \tstruct ustar_header header;\n \tunsigned int mode;\n@@ -241,7 +241,7 @@ static int write_tar_entry(struct archiver_args *args,\n \tstruct ustar_header header;\n \tstruct strbuf ext_header = STRBUF_INIT;\n \tunsigned int old_mode = mode;\n-\tunsigned long size, size_in_header;\n+\tsize_t size, size_in_header;\n \tvoid *buffer;\n \tint err = 0;\n \ndiff --git a/archive-zip.c b/archive-zip.c\nindex 155ee4a779..7bc9b8d425 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -297,7 +297,7 @@ static int write_zip_entry(struct archiver_args *args,\n \tvoid *buffer;\n \tstruct git_istream *stream = NULL;\n \tunsigned long flags = 0;\n-\tunsigned long size;\n+\tsize_t size;\n \tint is_binary = -1;\n \tconst char *path_without_prefix = path + args->baselen;\n \tunsigned int creator_version = 0;\ndiff --git a/archive.c b/archive.c\nindex 4d03134fd2..eb3613d2fe 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -74,7 +74,7 @@ static void format_subst(const struct commit *commit,\n void *object_file_to_archive(const struct archiver_args *args,\n \t\t\t     const char *path, const struct object_id *oid,\n \t\t\t     unsigned int mode, enum object_type *type,\n-\t\t\t     unsigned long *sizep)\n+\t\t\t     size_t *sizep)\n {\n \tvoid *buffer;\n \tconst struct commit *commit = args->convert ? args->commit : NULL;\ndiff --git a/archive.h b/archive.h\nindex 21ac010699..5b69ee1baf 100644\n--- a/archive.h\n+++ b/archive.h\n@@ -54,6 +54,6 @@ extern int write_archive_entries(struct archiver_args *args, write_archive_entry\n extern void *object_file_to_archive(const struct archiver_args *args,\n \t\t\t\t    const char *path, const struct object_id *oid,\n \t\t\t\t    unsigned int mode, enum object_type *type,\n-\t\t\t\t    unsigned long *sizep);\n+\t\t\t\t    size_t *sizep);\n \n #endif\t/* ARCHIVE_H */\ndiff --git a/bisect.c b/bisect.c\nindex cd9214f7ea..c7e7639b0c 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -137,7 +137,7 @@ static void show_list(const char *debug, int counted, int nr,\n \t\tstruct commit *commit = p->item;\n \t\tunsigned flags = commit->object.flags;\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf = repo_read_object_file(the_repository,\n \t\t\t\t\t\t  &commit->object.oid, &type,\n \t\t\t\t\t\t  &size);\ndiff --git a/blame.c b/blame.c\nindex e6e8220044..2711cef2a4 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -222,7 +222,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,\n \t\tstruct stat st;\n \t\tconst char *read_from;\n \t\tchar *buf_ptr;\n-\t\tunsigned long buf_len;\n+\t\tsize_t buf_len;\n \n \t\tif (contents_from) {\n \t\t\tif (stat(contents_from, &st) < 0)\n@@ -319,7 +319,7 @@ static void fill_origin_blob(struct diff_options *opt,\n {\n \tif (!o->file.ptr) {\n \t\tenum object_type type;\n-\t\tunsigned long file_size;\n+\t\tsize_t file_size;\n \n \t\t(*num_read_blob)++;\n \t\tif (opt->flags.allow_textconv &&\n@@ -1652,7 +1652,7 @@ static const char *get_next_line(const char *start, const char *end)\n static int prepare_lines(struct blame_scoreboard *sb)\n {\n \tconst char *buf = sb->final_buf;\n-\tunsigned long len = sb->final_buf_size;\n+\tsize_t len = sb->final_buf_size;\n \tconst char *end = buf + len;\n \tconst char *p;\n \tint *lineno;\ndiff --git a/blame.h b/blame.h\nindex be3a895043..0ef7ff1f3f 100644\n--- a/blame.h\n+++ b/blame.h\n@@ -112,7 +112,7 @@ struct blame_scoreboard {\n \t * indexed with scoreboard.lineno[blame_entry.lno].\n \t */\n \tconst char *final_buf;\n-\tunsigned long final_buf_size;\n+\tsize_t final_buf_size;\n \n \t/* linked list of blames */\n \tstruct blame_entry *ent;\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 787f91aadf..1676f30aea 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -30,7 +30,7 @@ static const char *force_path;\n \n static int filter_object(const char *path, unsigned mode,\n \t\t\t const struct object_id *oid,\n-\t\t\t char **buf, unsigned long *size)\n+\t\t\t char **buf, size_t *size)\n {\n \tenum object_type type;\n \n@@ -63,7 +63,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \tstruct object_id oid;\n \tenum object_type type;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tstruct object_context obj_context;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tstruct strbuf sb = STRBUF_INIT;\n@@ -192,7 +192,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n struct expand_data {\n \tstruct object_id oid;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \toff_t disk_size;\n \tconst char *rest;\n \tstruct object_id delta_base_oid;\n@@ -304,7 +304,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\t\tfflush(stdout);\n \t\tif (opt->cmdmode) {\n \t\t\tchar *contents;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \n \t\t\tif (!data->rest)\n \t\t\t\tdie(\"missing path for '%s'\", oid_to_hex(oid));\n@@ -336,7 +336,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t}\n \telse {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tvoid *contents;\n \n \t\tcontents = repo_read_object_file(the_repository, oid, &type,\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex 5e61162d08..8e118743e1 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -306,7 +306,7 @@ static char *get_symlink(const struct object_id *oid, const char *path)\n \t\tdata = strbuf_detach(&link, NULL);\n \t} else {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tdata = repo_read_object_file(the_repository, oid, &type,\n \t\t\t\t\t     &size);\n \t\tif (!data)\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex b8c2b3eec0..e1d806b134 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -226,7 +226,7 @@ static void show_progress(void)\n  * There's no need to cache this result with anonymize_mem, since\n  * we already handle blob content caching with marks.\n  */\n-static char *anonymize_blob(unsigned long *size)\n+static char *anonymize_blob(size_t *size)\n {\n \tstatic int counter;\n \tstruct strbuf out = STRBUF_INIT;\n@@ -237,7 +237,7 @@ static char *anonymize_blob(unsigned long *size)\n \n static void export_blob(const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf;\n \tstruct object *object;\n@@ -707,7 +707,7 @@ static void handle_tail(struct object_array *commits, struct rev_info *revs,\n \n static void handle_tag(const char *name, struct tag *tag)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf;\n \tconst char *tagger, *tagger_end, *message;\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex 05cbcba230..f17dd237d3 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -494,7 +494,8 @@ static void fmt_merge_msg_sigs(struct strbuf *out)\n \tfor (i = 0; i < origins.nr; i++) {\n \t\tstruct object_id *oid = origins.items[i].util;\n \t\tenum object_type type;\n-\t\tunsigned long size, len;\n+\t\tunsigned long len;\n+\t\tsize_t size;\n \t\tchar *buf = repo_read_object_file(the_repository, oid, &type,\n \t\t\t\t\t\t  &size);\n \t\tstruct strbuf sig = STRBUF_INIT;\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex f6be6cf0a3..0f41d4eeda 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -359,7 +359,7 @@ static void check_connectivity(void)\n \t}\n }\n \n-static int fsck_obj(struct object *obj, void *buffer, unsigned long size)\n+static int fsck_obj(struct object *obj, void *buffer, size_t size)\n {\n \tint err;\n \n@@ -407,7 +407,7 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)\n }\n \n static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,\n-\t\t\t   unsigned long size, void *buffer, int *eaten)\n+\t\t\t   size_t size, void *buffer, int *eaten)\n {\n \t/*\n \t * Note, buffer may be NULL if type is OBJ_BLOB. See\n@@ -562,7 +562,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)\n {\n \tstruct object *obj;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tvoid *contents;\n \tint eaten;\n \ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 19eb6b7935..15568c5ab2 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -294,7 +294,7 @@ static int grep_cmd_config(const char *var, const char *value, void *cb)\n \treturn st;\n }\n \n-static void *lock_and_read_oid_file(const struct object_id *oid, enum object_type *type, unsigned long *size)\n+static void *lock_and_read_oid_file(const struct object_id *oid, enum object_type *type, size_t *size)\n {\n \tvoid *data;\n \n@@ -447,7 +447,7 @@ static int grep_submodule(struct grep_opt *opt, struct repository *superproject,\n \t\tstruct object *object;\n \t\tstruct tree_desc tree;\n \t\tvoid *data;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tstruct strbuf base = STRBUF_INIT;\n \n \t\tobject = parse_object_or_die(oid, oid_to_hex(oid));\n@@ -576,7 +576,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\t\tenum object_type type;\n \t\t\tstruct tree_desc sub;\n \t\t\tvoid *data;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \n \t\t\tdata = lock_and_read_oid_file(entry.oid, &type, &size);\n \t\t\tif (!data)\n@@ -611,7 +611,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,\n \tif (obj->type == OBJ_COMMIT || obj->type == OBJ_TREE) {\n \t\tstruct tree_desc tree;\n \t\tvoid *data;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tstruct strbuf base;\n \t\tint hit, len;\n \ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 67f685fbcb..b49225416d 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -20,7 +20,7 @@ static const char index_pack_usage[] =\n \n struct object_entry {\n \tstruct pack_idx_entry idx;\n-\tunsigned long size;\n+\tsize_t size;\n \tunsigned char hdr_size;\n \tsigned char type;\n \tsigned char real_type;\n@@ -36,7 +36,7 @@ struct base_data {\n \tstruct base_data *child;\n \tstruct object_entry *obj;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ref_first, ref_last;\n \tint ofs_first, ofs_last;\n };\n@@ -198,7 +198,7 @@ static unsigned check_object(struct object *obj)\n \t\treturn 0;\n \n \tif (!(obj->flags & FLAG_CHECKED)) {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n \t\tif (type <= 0)\n \t\t\tdie(_(\"did not receive expected object %s\"),\n@@ -412,7 +412,7 @@ static int is_delta_type(enum object_type type)\n \treturn (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA);\n }\n \n-static void *unpack_entry_data(off_t offset, unsigned long size,\n+static void *unpack_entry_data(off_t offset, size_t size,\n \t\t\t       enum object_type type, struct object_id *oid)\n {\n \tstatic char fixed_buf[8192];\n@@ -467,7 +467,8 @@ static void *unpack_raw_entry(struct object_entry *obj,\n \t\t\t      struct object_id *oid)\n {\n \tunsigned char *p;\n-\tunsigned long size, c;\n+\tunsigned long c;\n+\tsize_t size;\n \toff_t base_offset;\n \tunsigned shift;\n \tvoid *data;\n@@ -529,7 +530,7 @@ static void *unpack_raw_entry(struct object_entry *obj,\n }\n \n static void *unpack_data(struct object_entry *obj,\n-\t\t\t int (*consume)(const unsigned char *, unsigned long, void *),\n+\t\t\t int (*consume)(const unsigned char *, size_t, void *),\n \t\t\t void *cb_data)\n {\n \toff_t from = obj[0].idx.offset + obj[0].hdr_size;\n@@ -706,10 +707,10 @@ struct compare_data {\n \tstruct object_entry *entry;\n \tstruct git_istream *st;\n \tunsigned char *buf;\n-\tunsigned long buf_size;\n+\tsize_t buf_size;\n };\n \n-static int compare_objects(const unsigned char *buf, unsigned long size,\n+static int compare_objects(const unsigned char *buf, size_t size,\n \t\t\t   void *cb_data)\n {\n \tstruct compare_data *data = cb_data;\n@@ -741,7 +742,7 @@ static int check_collison(struct object_entry *entry)\n {\n \tstruct compare_data data;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tif (entry->size <= big_file_threshold || entry->type != OBJ_BLOB)\n \t\treturn -1;\n@@ -761,7 +762,7 @@ static int check_collison(struct object_entry *entry)\n }\n \n static void sha1_object(const void *data, struct object_entry *obj_entry,\n-\t\t\tunsigned long size, enum object_type type,\n+\t\t\tsize_t size, enum object_type type,\n \t\t\tconst struct object_id *oid)\n {\n \tvoid *new_data = NULL;\n@@ -785,7 +786,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \tif (collision_test_needed) {\n \t\tvoid *has_data;\n \t\tenum object_type has_type;\n-\t\tunsigned long has_size;\n+\t\tsize_t has_size;\n \t\tread_lock();\n \t\thas_type = oid_object_info(the_repository, oid, &has_size);\n \t\tif (has_type < 0)\n@@ -1289,11 +1290,11 @@ static int write_compressed(struct hashfile *f, void *in, unsigned int size)\n \n static struct object_entry *append_obj_to_pack(struct hashfile *f,\n \t\t\t       const unsigned char *sha1, void *buf,\n-\t\t\t       unsigned long size, enum object_type type)\n+\t\t\t       size_t size, enum object_type type)\n {\n \tstruct object_entry *obj = &objects[nr_objects++];\n \tunsigned char header[10];\n-\tunsigned long s = size;\n+\tsize_t s = size;\n \tint n = 0;\n \tunsigned char c = (type << 4) | (s & 15);\n \ts >>= 4;\ndiff --git a/builtin/log.c b/builtin/log.c\nindex a619fdc6cf..71a4b40981 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -502,7 +502,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n \tstruct object_id oidc;\n \tstruct object_context obj_context;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tfflush(rev->diffopt.file);\n \tif (!rev->diffopt.flags.textconv_set_via_cmdline ||\n@@ -529,7 +529,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n \n static int show_tag_object(const struct object_id *oid, struct rev_info *rev)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf = repo_read_object_file(the_repository, oid, &type, &size);\n \tint offset = 0;\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex 7cad3f24eb..b4ceca9e25 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -94,7 +94,7 @@ static int show_tree(const struct object_id *oid, struct strbuf *base,\n \t\tif (ls_options & LS_SHOW_SIZE) {\n \t\t\tchar size_text[24];\n \t\t\tif (!strcmp(type, blob_type)) {\n-\t\t\t\tunsigned long size;\n+\t\t\t\tsize_t size;\n \t\t\t\tif (oid_object_info(the_repository, oid, &size) == OBJ_BAD)\n \t\t\t\t\txsnprintf(size_text, sizeof(size_text),\n \t\t\t\t\t\t  \"BAD\");\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 5ad9330c5a..2384fc9e82 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -55,7 +55,7 @@ static const char *explanation(struct merge_list *entry)\n \treturn \"removed in remote\";\n }\n \n-static void *result(struct merge_list *entry, unsigned long *size)\n+static void *result(struct merge_list *entry, size_t *size)\n {\n \tenum object_type type;\n \tstruct blob *base, *our, *their;\n@@ -81,7 +81,7 @@ static void *result(struct merge_list *entry, unsigned long *size)\n \treturn merge_blobs(&the_index, path, base, our, their, size);\n }\n \n-static void *origin(struct merge_list *entry, unsigned long *size)\n+static void *origin(struct merge_list *entry, size_t *size)\n {\n \tenum object_type type;\n \twhile (entry) {\n@@ -104,7 +104,7 @@ static int show_outf(void *priv_, mmbuffer_t *mb, int nbuf)\n \n static void show_diff(struct merge_list *entry)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tmmfile_t src, dst;\n \txpparam_t xpp;\n \txdemitconf_t xecfg;\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex be4366b03f..0e98682bfb 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -24,7 +24,7 @@ static int verify_object(const struct object_id *oid, const char *expected_type)\n {\n \tint ret = -1;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tvoid *buffer = repo_read_object_file(the_repository, oid, &type,\n \t\t\t\t\t     &size);\n \tconst struct object_id *repl = lookup_replace_object(the_repository, oid);\n@@ -37,7 +37,7 @@ static int verify_object(const struct object_id *oid, const char *expected_type)\n \treturn ret;\n }\n \n-static int verify_tag(char *buffer, unsigned long size)\n+static int verify_tag(char *buffer, size_t size)\n {\n \tint typelen;\n \tchar type[20];\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 218baa1038..3b60ba40a4 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -122,7 +122,7 @@ static int list_each_note(const struct object_id *object_oid,\n \n static void copy_obj_to_fd(int fd, const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf = repo_read_object_file(the_repository, oid, &type, &size);\n \tif (buf) {\n@@ -252,7 +252,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)\n \tchar *buf;\n \tstruct object_id object;\n \tenum object_type type;\n-\tunsigned long len;\n+\tsize_t len;\n \n \tBUG_ON_OPT_NEG(unset);\n \n@@ -613,7 +613,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)\n \n \tif (note && !edit) {\n \t\t/* Append buf to previous note contents */\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tenum object_type type;\n \t\tchar *prev_buf = repo_read_object_file(the_repository, note,\n \t\t\t\t\t\t       &type, &size);\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 04290124f4..d05622ad2c 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -142,7 +142,7 @@ static void index_commit_for_bitmap(struct commit *commit)\n \n static void *get_delta(struct object_entry *entry)\n {\n-\tunsigned long size, base_size, delta_size;\n+\tsize_t size, base_size, delta_size;\n \tvoid *buf, *base_buf, *delta_buf;\n \tenum object_type type;\n \n@@ -170,11 +170,11 @@ static void *get_delta(struct object_entry *entry)\n \treturn delta_buf;\n }\n \n-static unsigned long do_compress(void **pptr, unsigned long size)\n+static size_t do_compress(void **pptr, size_t size)\n {\n \tgit_zstream stream;\n \tvoid *in, *out;\n-\tunsigned long maxsize;\n+\tsize_t maxsize;\n \n \tgit_deflate_init(&stream, pack_compression_level);\n \tmaxsize = git_deflate_bound(&stream, size);\n@@ -195,13 +195,13 @@ static unsigned long do_compress(void **pptr, unsigned long size)\n \treturn stream.total_out;\n }\n \n-static unsigned long write_large_blob_data(struct git_istream *st, struct hashfile *f,\n+static size_t write_large_blob_data(struct git_istream *st, struct hashfile *f,\n \t\t\t\t\t   const struct object_id *oid)\n {\n \tgit_zstream stream;\n \tunsigned char ibuf[1024 * 16];\n \tunsigned char obuf[1024 * 16];\n-\tunsigned long olen = 0;\n+\tsize_t olen = 0;\n \n \tgit_deflate_init(&stream, pack_compression_level);\n \n@@ -242,7 +242,7 @@ static int check_pack_inflate(struct packed_git *p,\n \t\tstruct pack_window **w_curs,\n \t\toff_t offset,\n \t\toff_t len,\n-\t\tunsigned long expect)\n+\t\tsize_t expect)\n {\n \tgit_zstream stream;\n \tunsigned char fakebuf[4096], *in;\n@@ -284,10 +284,10 @@ static void copy_pack_data(struct hashfile *f,\n }\n \n /* Return 0 if we will bust the pack-size limit */\n-static unsigned long write_no_reuse_object(struct hashfile *f, struct object_entry *entry,\n-\t\t\t\t\t   unsigned long limit, int usable_delta)\n+static size_t write_no_reuse_object(struct hashfile *f, struct object_entry *entry,\n+\t\t\t\t\t   size_t limit, int usable_delta)\n {\n-\tunsigned long size, datalen;\n+\tsize_t size, datalen;\n \tunsigned char header[MAX_PACK_OBJECT_HEADER],\n \t\t      dheader[MAX_PACK_OBJECT_HEADER];\n \tunsigned hdrlen;\n@@ -398,7 +398,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent\n \n /* Return 0 if we will bust the pack-size limit */\n static off_t write_reuse_object(struct hashfile *f, struct object_entry *entry,\n-\t\t\t\tunsigned long limit, int usable_delta)\n+\t\t\t\tsize_t limit, int usable_delta)\n {\n \tstruct packed_git *p = IN_PACK(entry);\n \tstruct pack_window *w_curs = NULL;\n@@ -410,7 +410,7 @@ static off_t write_reuse_object(struct hashfile *f, struct object_entry *entry,\n \t\t      dheader[MAX_PACK_OBJECT_HEADER];\n \tunsigned hdrlen;\n \tconst unsigned hashsz = the_hash_algo->rawsz;\n-\tunsigned long entry_size = SIZE(entry);\n+\tsize_t entry_size = SIZE(entry);\n \n \tif (DELTA(entry))\n \t\ttype = (allow_ofs_delta && DELTA(entry)->idx.offset) ?\n@@ -481,7 +481,7 @@ static off_t write_object(struct hashfile *f,\n \t\t\t  struct object_entry *entry,\n \t\t\t  off_t write_offset)\n {\n-\tunsigned long limit;\n+\tsize_t limit;\n \toff_t len;\n \tint usable_delta, to_reuse;\n \n@@ -1212,7 +1212,7 @@ struct pbase_tree_cache {\n \tint ref;\n \tint temporary;\n \tvoid *tree_data;\n-\tunsigned long tree_size;\n+\tsize_t tree_size;\n };\n \n static struct pbase_tree_cache *(pbase_tree_cache[256]);\n@@ -1239,7 +1239,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)\n {\n \tstruct pbase_tree_cache *ent, *nent;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tint neigh;\n \tint my_ix = pbase_tree_cache_ix(oid);\n@@ -1422,7 +1422,7 @@ static void add_preferred_base(struct object_id *oid)\n {\n \tstruct pbase_tree *it;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tstruct object_id tree_oid;\n \n \tif (window <= num_preferred_base++)\n@@ -1526,7 +1526,7 @@ static int can_reuse_delta(const unsigned char *base_sha1,\n \n static void check_object(struct object_entry *entry)\n {\n-\tunsigned long canonical_size;\n+\tsize_t canonical_size;\n \n \tif (IN_PACK(entry)) {\n \t\tstruct packed_git *p = IN_PACK(entry);\n@@ -1538,7 +1538,7 @@ static void check_object(struct object_entry *entry)\n \t\toff_t ofs;\n \t\tunsigned char *buf, c;\n \t\tenum object_type type;\n-\t\tunsigned long in_pack_size;\n+\t\tsize_t in_pack_size;\n \n \t\tbuf = use_pack(p, &w_curs, entry->in_pack_offset, &avail);\n \n@@ -1704,7 +1704,7 @@ static void drop_reused_delta(struct object_entry *entry)\n \tunsigned *idx = &to_pack.objects[entry->delta_idx - 1].delta_child_idx;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \n \twhile (*idx) {\n \t\tstruct object_entry *oe = &to_pack.objects[*idx - 1];\n@@ -1941,8 +1941,8 @@ struct unpacked {\n \tunsigned depth;\n };\n \n-static int delta_cacheable(unsigned long src_size, unsigned long trg_size,\n-\t\t\t   unsigned long delta_size)\n+static int delta_cacheable(size_t src_size, size_t trg_size,\n+\t\t\t   size_t delta_size)\n {\n \tif (max_delta_cache_size && delta_cache_size + delta_size > max_delta_cache_size)\n \t\treturn 0;\n@@ -1987,14 +1987,14 @@ static pthread_mutex_t progress_mutex;\n  * reconstruction (so non-deltas are true object sizes, but deltas\n  * return the size of the delta data).\n  */\n-unsigned long oe_get_size_slow(struct packing_data *pack,\n+size_t oe_get_size_slow(struct packing_data *pack,\n \t\t\t       const struct object_entry *e)\n {\n \tstruct packed_git *p;\n \tstruct pack_window *w_curs;\n \tunsigned char *buf;\n \tenum object_type type;\n-\tunsigned long used, size;\n+\tsize_t used, size;\n \tsize_t avail;\n \n \tif (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {\n@@ -2024,11 +2024,11 @@ unsigned long oe_get_size_slow(struct packing_data *pack,\n }\n \n static int try_delta(struct unpacked *trg, struct unpacked *src,\n-\t\t     unsigned max_depth, unsigned long *mem_usage)\n+\t\t     unsigned max_depth, size_t *mem_usage)\n {\n \tstruct object_entry *trg_entry = trg->entry;\n \tstruct object_entry *src_entry = src->entry;\n-\tunsigned long trg_size, src_size, delta_size, sizediff, max_size, sz;\n+\tsize_t trg_size, src_size, delta_size, sizediff, max_size, sz;\n \tunsigned ref_depth;\n \tenum object_type type;\n \tvoid *delta_buf;\n@@ -2188,9 +2188,9 @@ static unsigned int check_delta_limit(struct object_entry *me, unsigned int n)\n \treturn m;\n }\n \n-static unsigned long free_unpacked(struct unpacked *n)\n+static size_t free_unpacked(struct unpacked *n)\n {\n-\tunsigned long freed_mem = sizeof_delta_index(n->index);\n+\tsize_t freed_mem = sizeof_delta_index(n->index);\n \tfree_delta_index(n->index);\n \tn->index = NULL;\n \tif (n->data) {\n@@ -2207,7 +2207,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,\n {\n \tuint32_t i, idx = 0, count = 0;\n \tstruct unpacked *array;\n-\tunsigned long mem_usage = 0;\n+\tsize_t mem_usage = 0;\n \n \tarray = xcalloc(window, sizeof(struct unpacked));\n \n@@ -2290,7 +2290,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,\n \t\t * between writes at that moment.\n \t\t */\n \t\tif (entry->delta_data && !pack_to_stdout) {\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \n \t\t\tsize = do_compress(&entry->delta_data, DELTA_SIZE(entry));\n \t\t\tif (size < (1U << OE_Z_DELTA_BITS)) {\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 7868026ade..babbd4ce0c 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -82,7 +82,7 @@ static int tree_is_complete(const struct object_id *oid)\n \n \tif (!tree->buffer) {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tvoid *data = repo_read_object_file(the_repository, oid, &type,\n \t\t\t\t\t\t   &size);\n \t\tif (!data) {\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex 1fad5f9502..b0def39a17 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -439,7 +439,7 @@ static int create_graft(int argc, const char **argv, int force, int gentle)\n \tstruct commit *commit;\n \tstruct strbuf buf = STRBUF_INIT;\n \tconst char *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tif (get_oid(old_ref, &old_oid) < 0)\n \t\treturn error(_(\"not a valid object name: '%s'\"), old_ref);\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 1011e17234..b1fe2f46af 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -165,7 +165,7 @@ static int git_tag_config(const char *var, const char *value, void *cb)\n \n static void write_tag_body(int fd, const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf, *sp;\n \n@@ -286,7 +286,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \tenum object_type type;\n \tstruct commit *c;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint subject_len = 0;\n \tconst char *subject_start;\n \ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex df4a47bae7..289839ad01 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -7,7 +7,7 @@ static char *create_temp_file(struct object_id *oid)\n \tstatic char path[50];\n \tvoid *buf;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tint fd;\n \n \tbuf = repo_read_object_file(the_repository, oid, &type, &size);\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex e27b21e9c2..7f2cac3037 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -32,7 +32,7 @@ static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;\n  */\n struct obj_buffer {\n \tchar *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n };\n \n static struct decoration obj_decorate;\n@@ -42,7 +42,7 @@ static struct obj_buffer *lookup_object_buffer(struct object *base)\n \treturn lookup_decoration(&obj_decorate, base);\n }\n \n-static void add_object_buffer(struct object *object, char *buffer, unsigned long size)\n+static void add_object_buffer(struct object *object, char *buffer, size_t size)\n {\n \tstruct obj_buffer *obj;\n \tobj = xcalloc(1, sizeof(struct obj_buffer));\n@@ -94,7 +94,7 @@ static void use(int bytes)\n \t\tdie(_(\"pack exceeds maximum allowed size\"));\n }\n \n-static void *get_data(unsigned long size)\n+static void *get_data(size_t size)\n {\n \tgit_zstream stream;\n \tvoid *buf = xmallocz(size);\n@@ -131,7 +131,7 @@ struct delta_info {\n \tstruct object_id base_oid;\n \tunsigned nr;\n \toff_t base_offset;\n-\tunsigned long size;\n+\tsize_t size;\n \tvoid *delta;\n \tstruct delta_info *next;\n };\n@@ -140,7 +140,7 @@ static struct delta_info *delta_list;\n \n static void add_delta_to_list(unsigned nr, const struct object_id *base_oid,\n \t\t\t      off_t base_offset,\n-\t\t\t      void *delta, unsigned long size)\n+\t\t\t      void *delta, size_t size)\n {\n \tstruct delta_info *info = xmalloc(sizeof(*info));\n \n@@ -199,7 +199,7 @@ static int check_object(struct object *obj, int type, void *data, struct fsck_op\n \t\tdie(\"object type mismatch\");\n \n \tif (!(obj->flags & FLAG_OPEN)) {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tint type = oid_object_info(the_repository, &obj->oid, &size);\n \t\tif (type != obj->type || type <= 0)\n \t\t\tdie(\"object of unexpected type\");\n@@ -229,7 +229,7 @@ static void write_rest(void)\n }\n \n static void added_object(unsigned nr, enum object_type type,\n-\t\t\t void *data, unsigned long size);\n+\t\t\t void *data, size_t size);\n \n /*\n  * Write out nr-th object from the list, now we know the contents\n@@ -237,7 +237,7 @@ static void added_object(unsigned nr, enum object_type type,\n  * to be checked at the end.\n  */\n static void write_object(unsigned nr, enum object_type type,\n-\t\t\t void *buf, unsigned long size)\n+\t\t\t void *buf, size_t size)\n {\n \tif (!strict) {\n \t\tif (write_object_file(buf, size, type_name(type),\n@@ -277,11 +277,11 @@ static void write_object(unsigned nr, enum object_type type,\n }\n \n static void resolve_delta(unsigned nr, enum object_type type,\n-\t\t\t  void *base, unsigned long base_size,\n-\t\t\t  void *delta, unsigned long delta_size)\n+\t\t\t  void *base, size_t base_size,\n+\t\t\t  void *delta, size_t delta_size)\n {\n \tvoid *result;\n-\tunsigned long result_size;\n+\tsize_t result_size;\n \n \tresult = patch_delta(base, base_size,\n \t\t\t     delta, delta_size,\n@@ -297,7 +297,7 @@ static void resolve_delta(unsigned nr, enum object_type type,\n  * resolve all the deltified objects that are based on it.\n  */\n static void added_object(unsigned nr, enum object_type type,\n-\t\t\t void *data, unsigned long size)\n+\t\t\t void *data, size_t size)\n {\n \tstruct delta_info **p = &delta_list;\n \tstruct delta_info *info;\n@@ -316,7 +316,7 @@ static void added_object(unsigned nr, enum object_type type,\n \t}\n }\n \n-static void unpack_non_delta_entry(enum object_type type, unsigned long size,\n+static void unpack_non_delta_entry(enum object_type type, size_t size,\n \t\t\t\t   unsigned nr)\n {\n \tvoid *buf = get_data(size);\n@@ -328,7 +328,7 @@ static void unpack_non_delta_entry(enum object_type type, unsigned long size,\n }\n \n static int resolve_against_held(unsigned nr, const struct object_id *base,\n-\t\t\t\tvoid *delta_data, unsigned long delta_size)\n+\t\t\t\tvoid *delta_data, size_t delta_size)\n {\n \tstruct object *obj;\n \tstruct obj_buffer *obj_buffer;\n@@ -343,11 +343,11 @@ static int resolve_against_held(unsigned nr, const struct object_id *base,\n \treturn 1;\n }\n \n-static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n+static void unpack_delta_entry(enum object_type type, size_t delta_size,\n \t\t\t       unsigned nr)\n {\n \tvoid *delta_data, *base;\n-\tunsigned long base_size;\n+\tsize_t base_size;\n \tstruct object_id base_oid;\n \n \tif (type == OBJ_REF_DELTA) {\n@@ -443,7 +443,8 @@ static void unpack_one(unsigned nr)\n {\n \tunsigned shift;\n \tunsigned char *pack;\n-\tunsigned long size, c;\n+\tunsigned long c;\n+\tsize_t size;\n \tenum object_type type;\n \n \tobj_list[nr].offset = consumed_bytes;\ndiff --git a/builtin/verify-commit.c b/builtin/verify-commit.c\nindex 3caa6cf8e9..1dc8104f3a 100644\n--- a/builtin/verify-commit.c\n+++ b/builtin/verify-commit.c\n@@ -21,7 +21,7 @@ static const char * const verify_commit_usage[] = {\n \t\tNULL\n };\n \n-static int run_gpg_verify(const struct object_id *oid, const char *buf, unsigned long size, unsigned flags)\n+static int run_gpg_verify(const struct object_id *oid, const char *buf, size_t size, unsigned flags)\n {\n \tstruct signature_check signature_check;\n \tint ret;\n@@ -41,7 +41,7 @@ static int verify_commit(const char *name, unsigned flags)\n \tenum object_type type;\n \tstruct object_id oid;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \tif (get_oid(name, &oid))\ndiff --git a/bundle.c b/bundle.c\nindex 1babd65ea9..b24dcf6279 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -217,7 +217,7 @@ int list_bundle_refs(struct bundle_header *header, int argc, const char **argv)\n \n static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf = NULL, *line, *lineend;\n \ttimestamp_t date;\ndiff --git a/cache.h b/cache.h\nindex cb53380211..aba5c0034c 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -784,7 +784,7 @@ extern int chmod_index_entry(struct index_state *, struct cache_entry *ce, char\n extern int ce_same_name(const struct cache_entry *a, const struct cache_entry *b);\n extern void set_object_name_for_intent_to_add_entry(struct cache_entry *ce);\n extern int index_name_is_other(const struct index_state *, const char *, int);\n-extern void *read_blob_data_from_index(const struct index_state *, const char *, unsigned long *);\n+extern void *read_blob_data_from_index(const struct index_state *, const char *, size_t *);\n \n /* do stat comparison even if CE_VALID is true */\n #define CE_MATCH_IGNORE_VALID\t\t01\n@@ -1281,10 +1281,10 @@ extern char *xdg_cache_home(const char *filename);\n \n extern int git_open_cloexec(const char *name, int flags);\n #define git_open(name) git_open_cloexec(name, O_RDONLY)\n-extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz);\n-extern int parse_sha1_header(const char *hdr, unsigned long *sizep);\n+extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, size_t mapsize, void *buffer, size_t bufsiz);\n+extern int parse_sha1_header(const char *hdr, size_t *sizep);\n \n-extern int check_object_signature(const struct object_id *oid, void *buf, unsigned long size, const char *type);\n+extern int check_object_signature(const struct object_id *oid, void *buf, size_t size, const char *type);\n \n extern int finalize_object_file(const char *tmpfile, const char *filename);\n \n@@ -1446,7 +1446,7 @@ extern int cache_name_stage_compare(const char *name1, int len1, int stage1, con\n \n extern void *read_object_with_reference(const struct object_id *oid,\n \t\t\t\t\tconst char *required_type,\n-\t\t\t\t\tunsigned long *size,\n+\t\t\t\t\tsize_t *size,\n \t\t\t\t\tstruct object_id *oid_ret);\n \n extern struct object *peel_to_type(const char *name, int namelen,\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 1f6cde4d43..64d5c3a22b 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -287,7 +287,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,\n \n static char *grab_blob(struct repository *r,\n \t\t       const struct object_id *oid, unsigned int mode,\n-\t\t       unsigned long *size, struct userdiff_driver *textconv,\n+\t\t       size_t *size, struct userdiff_driver *textconv,\n \t\t       const char *path)\n {\n \tchar *blob;\n@@ -379,7 +379,7 @@ static void consume_hunk(void *state_,\n \tstate->sline[state->nb-1].p_lno[state->n] = state->ob;\n }\n \n-static void consume_line(void *state_, char *line, unsigned long len)\n+static void consume_line(void *state_, char *line, size_t len)\n {\n \tstruct combine_diff_state *state = state_;\n \tif (!state->lost_bucket)\n@@ -409,7 +409,7 @@ static void combine_diff(struct repository *r,\n \txdemitconf_t xecfg;\n \tmmfile_t parent_file;\n \tstruct combine_diff_state state;\n-\tunsigned long sz;\n+\tsize_t sz;\n \n \tif (result_deleted)\n \t\treturn; /* result deleted */\n@@ -979,7 +979,8 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\t\t    struct rev_info *rev)\n {\n \tstruct diff_options *opt = &rev->diffopt;\n-\tunsigned long result_size, cnt, lno;\n+\tunsigned long cnt, lno;\n+\tsize_t result_size;\n \tint result_deleted = 0;\n \tchar *result, *cp;\n \tstruct sline *sline; /* survived lines */\n@@ -1097,7 +1098,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\tis_binary = buffer_is_binary(result, result_size);\n \t\tfor (i = 0; !is_binary && i < num_parent; i++) {\n \t\t\tchar *buf;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \t\t\tbuf = grab_blob(opt->repo,\n \t\t\t\t\t&elem->parent[i].oid,\n \t\t\t\t\telem->parent[i].mode,\ndiff --git a/commit.c b/commit.c\nindex c0c1d70b67..f1aed09134 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -260,7 +260,7 @@ int unregister_shallow(const struct object_id *oid)\n \n struct commit_buffer {\n \tvoid *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n };\n define_commit_slab(buffer_slab, struct commit_buffer);\n \n@@ -277,7 +277,7 @@ void free_commit_buffer_slab(struct buffer_slab *bs)\n \tfree(bs);\n }\n \n-void set_commit_buffer(struct repository *r, struct commit *commit, void *buffer, unsigned long size)\n+void set_commit_buffer(struct repository *r, struct commit *commit, void *buffer, size_t size)\n {\n \tstruct commit_buffer *v = buffer_slab_at(\n \t\tr->parsed_objects->buffer_slab, commit);\n@@ -285,7 +285,7 @@ void set_commit_buffer(struct repository *r, struct commit *commit, void *buffer\n \tv->size = size;\n }\n \n-const void *get_cached_commit_buffer(struct repository *r, const struct commit *commit, unsigned long *sizep)\n+const void *get_cached_commit_buffer(struct repository *r, const struct commit *commit, size_t *sizep)\n {\n \tstruct commit_buffer *v = buffer_slab_peek(\n \t\tr->parsed_objects->buffer_slab, commit);\n@@ -301,12 +301,12 @@ const void *get_cached_commit_buffer(struct repository *r, const struct commit *\n \n const void *repo_get_commit_buffer(struct repository *r,\n \t\t\t\t   const struct commit *commit,\n-\t\t\t\t   unsigned long *sizep)\n+\t\t\t\t   size_t *sizep)\n {\n \tconst void *ret = get_cached_commit_buffer(r, commit, sizep);\n \tif (!ret) {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tret = repo_read_object_file(r, &commit->object.oid, &type, &size);\n \t\tif (!ret)\n \t\t\tdie(\"cannot read commit object %s\",\n@@ -366,7 +366,7 @@ void release_commit_memory(struct parsed_object_pool *pool, struct commit *c)\n \tc->object.parsed = 0;\n }\n \n-const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)\n+const void *detach_commit_buffer(struct commit *commit, size_t *sizep)\n {\n \tstruct commit_buffer *v = buffer_slab_peek(\n \t\tthe_repository->parsed_objects->buffer_slab, commit);\n@@ -386,7 +386,7 @@ const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)\n \treturn ret;\n }\n \n-int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size, int check_graph)\n+int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, size_t size, int check_graph)\n {\n \tconst char *tail = buffer;\n \tconst char *bufptr = buffer;\n@@ -455,7 +455,7 @@ int repo_parse_commit_internal(struct repository *r,\n {\n \tenum object_type type;\n \tvoid *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \tif (!item)\n@@ -976,7 +976,7 @@ int parse_signed_commit(const struct commit *commit,\n \t\t\tstruct strbuf *payload, struct strbuf *signature)\n {\n \n-\tunsigned long size;\n+\tsize_t size;\n \tconst char *buffer = get_commit_buffer(commit, &size);\n \tint in_signature, saw_signature = -1;\n \tconst char *line, *tail;\n@@ -1051,7 +1051,7 @@ static void handle_signed_tag(struct commit *parent, struct commit_extra_header\n \tstruct merge_remote_desc *desc;\n \tstruct commit_extra_header *mergetag;\n \tchar *buf;\n-\tunsigned long size, len;\n+\tsize_t size, len;\n \tenum object_type type;\n \n \tdesc = merge_remote_util(parent);\n@@ -1159,7 +1159,7 @@ struct commit_extra_header *read_commit_extra_headers(struct commit *commit,\n \t\t\t\t\t\t      const char **exclude)\n {\n \tstruct commit_extra_header *extra = NULL;\n-\tunsigned long size;\n+\tsize_t size;\n \tconst char *buffer = get_commit_buffer(commit, &size);\n \textra = read_commit_extra_header_lines(buffer, size, exclude);\n \trepo_unuse_commit_buffer(the_repository, commit, buffer);\ndiff --git a/commit.h b/commit.h\nindex 42728c2906..bcf3227b85 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -79,7 +79,7 @@ struct commit *lookup_commit_reference_by_name(const char *name);\n  */\n struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name);\n \n-int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size, int check_graph);\n+int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, size_t size, int check_graph);\n int repo_parse_commit_internal(struct repository *r, struct commit *item,\n \t\t\t       int quiet_on_missing, int use_commit_graph);\n int repo_parse_commit_gently(struct repository *r,\n@@ -105,13 +105,13 @@ void free_commit_buffer_slab(struct buffer_slab *bs);\n  * Associate an object buffer with the commit. The ownership of the\n  * memory is handed over to the commit, and must be free()-able.\n  */\n-void set_commit_buffer(struct repository *r, struct commit *, void *buffer, unsigned long size);\n+void set_commit_buffer(struct repository *r, struct commit *, void *buffer, size_t size);\n \n /*\n  * Get any cached object buffer associated with the commit. Returns NULL\n  * if none. The resulting memory should not be freed.\n  */\n-const void *get_cached_commit_buffer(struct repository *, const struct commit *, unsigned long *size);\n+const void *get_cached_commit_buffer(struct repository *, const struct commit *, size_t *size);\n \n /*\n  * Get the commit's object contents, either from cache or by reading the object\n@@ -120,7 +120,7 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *,\n  */\n const void *repo_get_commit_buffer(struct repository *r,\n \t\t\t\t   const struct commit *,\n-\t\t\t\t   unsigned long *size);\n+\t\t\t\t   size_t *size);\n #ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS\n #define get_commit_buffer(c, s) repo_get_commit_buffer(the_repository, c, s)\n #endif\n@@ -156,7 +156,7 @@ void release_commit_memory(struct parsed_object_pool *pool, struct commit *c);\n  * Disassociate any cached object buffer from the commit, but do not free it.\n  * The buffer (or NULL, if none) is returned.\n  */\n-const void *detach_commit_buffer(struct commit *, unsigned long *sizep);\n+const void *detach_commit_buffer(struct commit *, size_t *sizep);\n \n /* Find beginning and length of commit subject. */\n int find_commit_subject(const char *commit_buffer, const char **subject);\ndiff --git a/config.c b/config.c\nindex 2032a051e8..1178293d30 100644\n--- a/config.c\n+++ b/config.c\n@@ -1594,7 +1594,7 @@ int git_config_from_blob_oid(config_fn_t fn,\n {\n \tenum object_type type;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \tbuf = repo_read_object_file(the_repository, oid, &type, &size);\ndiff --git a/convert.c b/convert.c\nindex e0848226d2..f66b23c2bf 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -43,9 +43,9 @@ struct text_stat {\n \tunsigned printable, nonprintable;\n };\n \n-static void gather_stats(const char *buf, unsigned long size, struct text_stat *stats)\n+static void gather_stats(const char *buf, size_t size, struct text_stat *stats)\n {\n-\tunsigned long i;\n+\tsize_t i;\n \n \tmemset(stats, 0, sizeof(*stats));\n \n@@ -92,7 +92,7 @@ static void gather_stats(const char *buf, unsigned long size, struct text_stat *\n  * The same heuristics as diff.c::mmfile_is_binary()\n  * We treat files with bare CR as binary\n  */\n-static int convert_is_binary(unsigned long size, const struct text_stat *stats)\n+static int convert_is_binary(size_t size, const struct text_stat *stats)\n {\n \tif (stats->lonecr)\n \t\treturn 1;\n@@ -103,7 +103,7 @@ static int convert_is_binary(unsigned long size, const struct text_stat *stats)\n \treturn 0;\n }\n \n-static unsigned int gather_convert_stats(const char *data, unsigned long size)\n+static unsigned int gather_convert_stats(const char *data, size_t size)\n {\n \tstruct text_stat stats;\n \tint ret = 0;\n@@ -120,7 +120,7 @@ static unsigned int gather_convert_stats(const char *data, unsigned long size)\n \treturn ret;\n }\n \n-static const char *gather_convert_stats_ascii(const char *data, unsigned long size)\n+static const char *gather_convert_stats_ascii(const char *data, size_t size)\n {\n \tunsigned int convert_stats = gather_convert_stats(data, size);\n \n@@ -142,7 +142,7 @@ const char *get_cached_convert_stats_ascii(const struct index_state *istate,\n \t\t\t\t\t   const char *path)\n {\n \tconst char *ret;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tvoid *data = read_blob_data_from_index(istate, path, &sz);\n \tret = gather_convert_stats_ascii(data, sz);\n \tfree(data);\n@@ -224,7 +224,7 @@ static void check_global_conv_flags_eol(const char *path, enum crlf_action crlf_\n \n static int has_crlf_in_index(const struct index_state *istate, const char *path)\n {\n-\tunsigned long sz;\n+\tsize_t sz;\n \tvoid *data;\n \tconst char *crp;\n \tint has_crlf = 0;\n@@ -630,7 +630,7 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,\n \n struct filter_params {\n \tconst char *src;\n-\tunsigned long size;\n+\tsize_t size;\n \tint fd;\n \tconst char *cmd;\n \tconst char *path;\n@@ -1048,7 +1048,7 @@ static int read_convert_config(const char *var, const char *value, void *cb)\n \treturn 0;\n }\n \n-static int count_ident(const char *cp, unsigned long size)\n+static int count_ident(const char *cp, size_t size)\n {\n \t/*\n \t * \"$Id: 0000000000000000000000000000000000000000 $\" <=> \"$Id$\"\ndiff --git a/delta.h b/delta.h\nindex 9b67531dfa..541171230c 100644\n--- a/delta.h\n+++ b/delta.h\n@@ -42,8 +42,8 @@ extern unsigned long sizeof_delta_index(struct delta_index *index);\n  */\n extern void *\n create_delta(const struct delta_index *index,\n-\t     const void *buf, unsigned long bufsize,\n-\t     unsigned long *delta_size, unsigned long max_delta_size);\n+\t     const void *buf, size_t bufsize,\n+\t     size_t *delta_size, size_t max_delta_size);\n \n /*\n  * diff_delta: create a delta from source buffer to target buffer\n@@ -54,9 +54,9 @@ create_delta(const struct delta_index *index,\n  * updated with its size.  The returned buffer must be freed by the caller.\n  */\n static inline void *\n-diff_delta(const void *src_buf, unsigned long src_bufsize,\n-\t   const void *trg_buf, unsigned long trg_bufsize,\n-\t   unsigned long *delta_size, unsigned long max_delta_size)\n+diff_delta(const void *src_buf, size_t src_bufsize,\n+\t   const void *trg_buf, size_t trg_bufsize,\n+\t   size_t *delta_size, size_t max_delta_size)\n {\n \tstruct delta_index *index = create_delta_index(src_buf, src_bufsize);\n \tif (index) {\n@@ -75,9 +75,9 @@ diff_delta(const void *src_buf, unsigned long src_bufsize,\n  * *trg_bufsize is updated with its size.  On failure a NULL pointer is\n  * returned.  The returned buffer must be freed by the caller.\n  */\n-extern void *patch_delta(const void *src_buf, unsigned long src_size,\n-\t\t\t const void *delta_buf, unsigned long delta_size,\n-\t\t\t unsigned long *dst_size);\n+extern void *patch_delta(const void *src_buf, size_t src_size,\n+\t\t\t const void *delta_buf, size_t delta_size,\n+\t\t\t size_t *dst_size);\n \n /* the smallest possible delta size is 4 bytes */\n #define DELTA_SIZE_MIN\t4\n@@ -86,11 +86,11 @@ extern void *patch_delta(const void *src_buf, unsigned long src_size,\n  * This must be called twice on the delta data buffer, first to get the\n  * expected source buffer size, and again to get the target buffer size.\n  */\n-static inline unsigned long get_delta_hdr_size(const unsigned char **datap,\n+static inline size_t get_delta_hdr_size(const unsigned char **datap,\n \t\t\t\t\t       const unsigned char *top)\n {\n \tconst unsigned char *data = *datap;\n-\tunsigned long cmd, size = 0;\n+\tsize_t cmd, size = 0;\n \tint i = 0;\n \tdo {\n \t\tcmd = *data++;\ndiff --git a/diff-delta.c b/diff-delta.c\nindex e49643353b..072a5ca839 100644\n--- a/diff-delta.c\n+++ b/diff-delta.c\n@@ -316,8 +316,8 @@ unsigned long sizeof_delta_index(struct delta_index *index)\n \n void *\n create_delta(const struct delta_index *index,\n-\t     const void *trg_buf, unsigned long trg_size,\n-\t     unsigned long *delta_size, unsigned long max_size)\n+\t     const void *trg_buf, size_t trg_size,\n+\t     size_t *delta_size, size_t max_size)\n {\n \tunsigned int i, val;\n \toff_t outpos, moff;\ndiff --git a/diff.c b/diff.c\nindex deb3697c16..12266586f3 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2258,7 +2258,7 @@ static void find_lno(const char *line, struct emit_callback *ecbdata)\n \tecbdata->lno_in_postimage = strtol(p + 1, NULL, 10);\n }\n \n-static void fn_out_consume(void *priv, char *line, unsigned long len)\n+static void fn_out_consume(void *priv, char *line, size_t len)\n {\n \tstruct emit_callback *ecbdata = priv;\n \tconst char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);\n@@ -2461,7 +2461,7 @@ static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,\n \treturn x;\n }\n \n-static void diffstat_consume(void *priv, char *line, unsigned long len)\n+static void diffstat_consume(void *priv, char *line, size_t len)\n {\n \tstruct diffstat_t *diffstat = priv;\n \tstruct diffstat_file *x = diffstat->files[diffstat->nr - 1];\n@@ -3141,7 +3141,7 @@ static void checkdiff_consume_hunk(void *priv,\n \tdata->lineno = nb - 1;\n }\n \n-static void checkdiff_consume(void *priv, char *line, unsigned long len)\n+static void checkdiff_consume(void *priv, char *line, size_t len)\n {\n \tstruct checkdiff_t *data = priv;\n \tint marker_size = data->conflict_marker_size;\n@@ -3180,8 +3180,8 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)\n }\n \n static unsigned char *deflate_it(char *data,\n-\t\t\t\t unsigned long size,\n-\t\t\t\t unsigned long *result_size)\n+\t\t\t\t size_t size,\n+\t\t\t\t size_t *result_size)\n {\n \tint bound;\n \tunsigned char *deflated;\n@@ -3209,10 +3209,10 @@ static void emit_binary_diff_body(struct diff_options *o,\n \tvoid *delta;\n \tvoid *deflated;\n \tvoid *data;\n-\tunsigned long orig_size;\n-\tunsigned long delta_size;\n-\tunsigned long deflate_size;\n-\tunsigned long data_size;\n+\tsize_t orig_size;\n+\tsize_t delta_size;\n+\tsize_t deflate_size;\n+\tsize_t data_size;\n \n \t/* We could do deflated delta, or we could do just deflated two,\n \t * whichever is smaller.\n@@ -3998,7 +3998,7 @@ void diff_free_filespec_data(struct diff_filespec *s)\n static void prep_temp_blob(struct index_state *istate,\n \t\t\t   const char *path, struct diff_tempfile *temp,\n \t\t\t   void *blob,\n-\t\t\t   unsigned long size,\n+\t\t\t   size_t size,\n \t\t\t   const struct object_id *oid,\n \t\t\t   int mode)\n {\n@@ -5658,9 +5658,9 @@ struct patch_id_t {\n \tint patchlen;\n };\n \n-static int remove_space(char *line, int len)\n+static size_t remove_space(char *line, size_t len)\n {\n-\tint i;\n+\tsize_t i;\n \tchar *dst = line;\n \tunsigned char c;\n \n@@ -5671,10 +5671,10 @@ static int remove_space(char *line, int len)\n \treturn dst - line;\n }\n \n-static void patch_id_consume(void *priv, char *line, unsigned long len)\n+static void patch_id_consume(void *priv, char *line, size_t len)\n {\n \tstruct patch_id_t *data = priv;\n-\tint new_len;\n+\tsize_t new_len;\n \n \tnew_len = remove_space(line, len);\n \n@@ -6435,7 +6435,7 @@ int textconv_object(struct repository *r,\n \t\t    const struct object_id *oid,\n \t\t    int oid_valid,\n \t\t    char **buf,\n-\t\t    unsigned long *buf_size)\n+\t\t    size_t *buf_size)\n {\n \tstruct diff_filespec *df;\n \tstruct userdiff_driver *textconv;\ndiff --git a/diff.h b/diff.h\nindex b512d0477a..9faeab924e 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -474,7 +474,7 @@ int textconv_object(struct repository *repo,\n \t\t    const char *path,\n \t\t    unsigned mode,\n \t\t    const struct object_id *oid, int oid_valid,\n-\t\t    char **buf, unsigned long *buf_size);\n+\t\t    char **buf, size_t *buf_size);\n \n int parse_rename_score(const char **cp_p);\n \ndiff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c\nindex ad939d2861..d78b510465 100644\n--- a/diffcore-pickaxe.c\n+++ b/diffcore-pickaxe.c\n@@ -19,7 +19,7 @@ struct diffgrep_cb {\n \tint hit;\n };\n \n-static void diffgrep_consume(void *priv, char *line, unsigned long len)\n+static void diffgrep_consume(void *priv, char *line, size_t len)\n {\n \tstruct diffgrep_cb *data = priv;\n \tregmatch_t regmatch;\n@@ -71,7 +71,7 @@ static int diff_grep(mmfile_t *one, mmfile_t *two,\n static unsigned int contains(mmfile_t *mf, regex_t *regexp, kwset_t kws)\n {\n \tunsigned int cnt;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tconst char *data;\n \n \tsz = mf->size;\ndiff --git a/diffcore.h b/diffcore.h\nindex b651061c0e..b47778dd36 100644\n--- a/diffcore.h\n+++ b/diffcore.h\n@@ -33,7 +33,7 @@ struct diff_filespec {\n \tchar *path;\n \tvoid *data;\n \tvoid *cnt_data;\n-\tunsigned long size;\n+\tsize_t size;\n \tint count;               /* Reference count */\n \tint rename_used;         /* Count of rename users */\n \tunsigned short mode;\t /* file mode */\ndiff --git a/dir.c b/dir.c\nindex 34d0ecb469..893576f544 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -183,7 +183,7 @@ static size_t common_prefix_len(const struct pathspec *pathspec)\n  */\n char *common_prefix(const struct pathspec *pathspec)\n {\n-\tunsigned long len = common_prefix_len(pathspec);\n+\tsize_t len = common_prefix_len(pathspec);\n \n \treturn len ? xmemdupz(pathspec->items[0].match, len) : NULL;\n }\n@@ -239,7 +239,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,\n \t\t\tsize_t *size_out, char **data_out)\n {\n \tenum object_type type;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tchar *data;\n \n \t*size_out = 0;\n@@ -2826,7 +2826,7 @@ static void load_oid_stat(struct oid_stat *oid_stat, const unsigned char *data,\n \toid_stat->valid = 1;\n }\n \n-struct untracked_cache *read_untracked_extension(const void *data, unsigned long sz)\n+struct untracked_cache *read_untracked_extension(const void *data, size_t sz)\n {\n \tstruct untracked_cache *uc;\n \tstruct read_data rd;\ndiff --git a/dir.h b/dir.h\nindex e3ec26143d..7dc741cd41 100644\n--- a/dir.h\n+++ b/dir.h\n@@ -360,7 +360,7 @@ void untracked_cache_remove_from_index(struct index_state *, const char *);\n void untracked_cache_add_to_index(struct index_state *, const char *);\n \n void free_untracked_cache(struct untracked_cache *);\n-struct untracked_cache *read_untracked_extension(const void *data, unsigned long sz);\n+struct untracked_cache *read_untracked_extension(const void *data, size_t sz);\n void write_untracked_extension(struct strbuf *out, struct untracked_cache *untracked);\n void add_untracked_cache(struct index_state *istate);\n void remove_untracked_cache(struct index_state *istate);\ndiff --git a/entry.c b/entry.c\nindex ee87c355b1..4f4ea27587 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -83,7 +83,7 @@ static int create_file(const char *path, unsigned int mode)\n \treturn open(path, O_WRONLY | O_CREAT | O_EXCL, mode);\n }\n \n-static void *read_blob_entry(const struct cache_entry *ce, unsigned long *size)\n+static void *read_blob_entry(const struct cache_entry *ce, size_t *size)\n {\n \tenum object_type type;\n \tvoid *blob_data = repo_read_object_file(the_repository, &ce->oid,\n@@ -260,7 +260,7 @@ static int write_entry(struct cache_entry *ce,\n \tint fd, ret, fstat_done = 0;\n \tchar *new_blob;\n \tstruct strbuf buf = STRBUF_INIT;\n-\tunsigned long size;\n+\tsize_t size;\n \tssize_t wrote;\n \tsize_t newsize = 0;\n \tstruct stat st;\ndiff --git a/fast-import.c b/fast-import.c\nindex 5d4a6f1b19..c8f7f0cedd 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -895,7 +895,7 @@ static int store_object(\n \tstruct object_entry *e;\n \tunsigned char hdr[96];\n \tstruct object_id oid;\n-\tunsigned long hdrlen, deltalen;\n+\tsize_t hdrlen, deltalen;\n \tgit_hash_ctx c;\n \tgit_zstream s;\n \n@@ -1036,7 +1036,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)\n \tunsigned char *out_buf = xmalloc(out_sz);\n \tstruct object_entry *e;\n \tstruct object_id oid;\n-\tunsigned long hdrlen;\n+\tsize_t hdrlen;\n \toff_t offset;\n \tgit_hash_ctx c;\n \tgit_zstream s;\n@@ -1154,7 +1154,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)\n  */\n static void *gfi_unpack_entry(\n \tstruct object_entry *oe,\n-\tunsigned long *sizep)\n+\tsize_t *sizep)\n {\n \tenum object_type type;\n \tstruct packed_git *p = all_packs[oe->pack_id];\n@@ -1200,7 +1200,7 @@ static void load_tree(struct tree_entry *root)\n \tstruct object_id *oid = &root->versions[1].oid;\n \tstruct object_entry *myoe;\n \tstruct tree_content *t;\n-\tunsigned long size;\n+\tsize_t size;\n \tchar *buf;\n \tconst char *c;\n \n@@ -1873,7 +1873,7 @@ static int validate_raw_date(const char *src, struct strbuf *result)\n {\n \tconst char *orig_src = src;\n \tchar *endp;\n-\tunsigned long num;\n+\tsize_t num;\n \n \terrno = 0;\n \n@@ -2400,7 +2400,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", commit_mark);\n \t\toidcpy(&commit_oid, &commit_oe->idx.oid);\n \t} else if (!get_oid(p, &commit_oid)) {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf = read_object_with_reference(&commit_oid,\n \t\t\t\t\t\t       commit_type, &size,\n \t\t\t\t\t\t       &commit_oid);\n@@ -2453,7 +2453,7 @@ static void file_change_deleteall(struct branch *b)\n \tb->num_notes = 0;\n }\n \n-static void parse_from_commit(struct branch *b, char *buf, unsigned long size)\n+static void parse_from_commit(struct branch *b, char *buf, size_t size)\n {\n \tif (!buf || size < GIT_SHA1_HEXSZ + 6)\n \t\tdie(\"Not a valid commit: %s\", oid_to_hex(&b->oid));\n@@ -2470,7 +2470,7 @@ static void parse_from_existing(struct branch *b)\n \t\toidclr(&b->branch_tree.versions[0].oid);\n \t\toidclr(&b->branch_tree.versions[1].oid);\n \t} else {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf;\n \n \t\tbuf = read_object_with_reference(&b->oid, commit_type, &size,\n@@ -2507,7 +2507,7 @@ static int parse_from(struct branch *b)\n \t\tif (!oideq(&b->oid, &oe->idx.oid)) {\n \t\t\toidcpy(&b->oid, &oe->idx.oid);\n \t\t\tif (oe->pack_id != MAX_PACK_ID) {\n-\t\t\t\tunsigned long size;\n+\t\t\t\tsize_t size;\n \t\t\t\tchar *buf = gfi_unpack_entry(oe, &size);\n \t\t\t\tparse_from_commit(b, buf, size);\n \t\t\t\tfree(buf);\n@@ -2550,7 +2550,7 @@ static struct hash_list *parse_merge(unsigned int *count)\n \t\t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", idnum);\n \t\t\toidcpy(&n->oid, &oe->idx.oid);\n \t\t} else if (!get_oid(from, &n->oid)) {\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \t\t\tchar *buf = read_object_with_reference(&n->oid,\n \t\t\t\t\t\t\t       commit_type,\n \t\t\t\t\t\t\t       &size, &n->oid);\n@@ -2776,7 +2776,7 @@ static void parse_reset_branch(const char *arg)\n \t\tunread_command_buf = 1;\n }\n \n-static void cat_blob_write(const char *buf, unsigned long size)\n+static void cat_blob_write(const char *buf, size_t size)\n {\n \tif (write_in_full(cat_blob_fd, buf, size) < 0)\n \t\tdie_errno(\"Write to frontend failed\");\n@@ -2785,7 +2785,7 @@ static void cat_blob_write(const char *buf, unsigned long size)\n static void cat_blob(struct object_entry *oe, struct object_id *oid)\n {\n \tstruct strbuf line = STRBUF_INIT;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type = 0;\n \tchar *buf;\n \n@@ -2869,7 +2869,7 @@ static void parse_cat_blob(const char *p)\n static struct object_entry *dereference(struct object_entry *oe,\n \t\t\t\t\tstruct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tchar *buf = NULL;\n \tif (!oe) {\n \t\tenum object_type type = oid_object_info(the_repository, oid,\ndiff --git a/fsck.c b/fsck.c\nindex a0006dfe5c..b6d4291546 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -850,7 +850,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,\n }\n \n static int fsck_commit(struct commit *commit, const char *data,\n-\tunsigned long size, struct fsck_options *options)\n+\tsize_t size, struct fsck_options *options)\n {\n \tconst char *buffer = data ?  data : get_commit_buffer(commit, &size);\n \tint ret = fsck_commit_buffer(commit, buffer, size, options);\n@@ -860,7 +860,7 @@ static int fsck_commit(struct commit *commit, const char *data,\n }\n \n static int fsck_tag_buffer(struct tag *tag, const char *data,\n-\tunsigned long size, struct fsck_options *options)\n+\tsize_t size, struct fsck_options *options)\n {\n \tstruct object_id oid;\n \tint ret = 0;\n@@ -956,7 +956,7 @@ static int fsck_tag_buffer(struct tag *tag, const char *data,\n }\n \n static int fsck_tag(struct tag *tag, const char *data,\n-\tunsigned long size, struct fsck_options *options)\n+\tsize_t size, struct fsck_options *options)\n {\n \tstruct object *tagged = tag->tagged;\n \n@@ -1007,7 +1007,7 @@ static int fsck_gitmodules_fn(const char *var, const char *value, void *vdata)\n }\n \n static int fsck_blob(struct blob *blob, const char *buf,\n-\t\t     unsigned long size, struct fsck_options *options)\n+\t\t     size_t size, struct fsck_options *options)\n {\n \tstruct fsck_gitmodules_data data;\n \tstruct config_options config_opts = { 0 };\n@@ -1043,7 +1043,7 @@ static int fsck_blob(struct blob *blob, const char *buf,\n \treturn data.ret;\n }\n \n-int fsck_object(struct object *obj, void *data, unsigned long size,\n+int fsck_object(struct object *obj, void *data, size_t size,\n \tstruct fsck_options *options)\n {\n \tif (!obj)\n@@ -1085,7 +1085,7 @@ int fsck_finish(struct fsck_options *options)\n \twhile ((oid = oidset_iter_next(&iter))) {\n \t\tstruct blob *blob;\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf;\n \n \t\tif (oidset_contains(&gitmodules_done, oid))\ndiff --git a/fsck.h b/fsck.h\nindex b95595ae5f..939ccf856b 100644\n--- a/fsck.h\n+++ b/fsck.h\n@@ -53,7 +53,7 @@ struct fsck_options {\n  */\n int fsck_walk(struct object *obj, void *data, struct fsck_options *options);\n /* If NULL is passed for data, we assume the object is local and read it. */\n-int fsck_object(struct object *obj, void *data, unsigned long size,\n+int fsck_object(struct object *obj, void *data, size_t size,\n \tstruct fsck_options *options);\n \n /*\ndiff --git a/fuzz-pack-headers.c b/fuzz-pack-headers.c\nindex 99da1d0fd3..d04e264e23 100644\n--- a/fuzz-pack-headers.c\n+++ b/fuzz-pack-headers.c\n@@ -5,10 +5,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);\n int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)\n {\n \tenum object_type type;\n-\tunsigned long len;\n+\tsize_t len;\n \n \tunpack_object_header_buffer((const unsigned char *)data,\n-\t\t\t\t    (unsigned long)size, &type, &len);\n+\t\t\t\t    size, &type, &len);\n \n \treturn 0;\n }\ndiff --git a/grep.h b/grep.h\nindex fb04893721..5765213f4b 100644\n--- a/grep.h\n+++ b/grep.h\n@@ -209,7 +209,7 @@ struct grep_source {\n \tvoid *identifier;\n \n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tchar *path; /* for attribute lookups */\n \tstruct userdiff_driver *driver;\ndiff --git a/http-push.c b/http-push.c\nindex 42815c42d1..88c49d3c27 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -359,7 +359,7 @@ static void start_put(struct transfer_request *request)\n \tenum object_type type;\n \tchar hdr[50];\n \tvoid *unpacked;\n-\tunsigned long len;\n+\tsize_t len;\n \tint hdrlen;\n \tssize_t size;\n \tgit_zstream stream;\ndiff --git a/list-objects-filter.c b/list-objects-filter.c\nindex a62624a1ce..ef31a7660e 100644\n--- a/list-objects-filter.c\n+++ b/list-objects-filter.c\n@@ -154,7 +154,7 @@ static enum list_objects_filter_result filter_blobs_limit(\n \tvoid *filter_data_)\n {\n \tstruct filter_blobs_limit_data *filter_data = filter_data_;\n-\tunsigned long object_length;\n+\tsize_t object_length;\n \tenum object_type t;\n \n \tswitch (filter_situation) {\ndiff --git a/mailmap.c b/mailmap.c\nindex f3ffea0e17..088bea4325 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -217,7 +217,7 @@ static int read_mailmap_blob(struct string_list *map,\n {\n \tstruct object_id oid;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \n \tif (!name)\ndiff --git a/match-trees.c b/match-trees.c\nindex 8d9f43e9c9..62f53dae27 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -53,7 +53,7 @@ static void *fill_tree_desc_strict(struct tree_desc *desc,\n {\n \tvoid *buffer;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tbuffer = repo_read_object_file(the_repository, hash, &type, &size);\n \tif (!buffer)\n@@ -177,7 +177,7 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,\n \tchar *subpath;\n \tint toplen;\n \tchar *buf;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tstruct tree_desc desc;\n \tstruct object_id *rewrite_here;\n \tconst struct object_id *rewrite_with;\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex 757e338715..ba67132044 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -9,7 +9,7 @@\n static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n {\n \tvoid *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \n \tbuf = repo_read_object_file(the_repository, &obj->object.oid, &type,\n@@ -35,7 +35,7 @@ static void *three_way_filemerge(struct index_state *istate,\n \t\t\t\t mmfile_t *base,\n \t\t\t\t mmfile_t *our,\n \t\t\t\t mmfile_t *their,\n-\t\t\t\t unsigned long *size)\n+\t\t\t\t size_t *size)\n {\n \tint merge_status;\n \tmmbuffer_t res;\n@@ -58,7 +58,7 @@ static void *three_way_filemerge(struct index_state *istate,\n \n void *merge_blobs(struct index_state *istate, const char *path,\n \t\t  struct blob *base, struct blob *our,\n-\t\t  struct blob *their, unsigned long *size)\n+\t\t  struct blob *their, size_t *size)\n {\n \tvoid *res = NULL;\n \tmmfile_t f1, f2, common;\ndiff --git a/merge-blobs.h b/merge-blobs.h\nindex cc31038b80..7f37952b0e 100644\n--- a/merge-blobs.h\n+++ b/merge-blobs.h\n@@ -6,6 +6,6 @@ struct index_state;\n \n extern void *merge_blobs(struct index_state *, const char *,\n \t\t\t struct blob *, struct blob *,\n-\t\t\t struct blob *, unsigned long *);\n+\t\t\t struct blob *, size_t *);\n \n #endif /* MERGE_BLOBS_H */\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 4d8415ce52..e8484f5798 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -951,7 +951,7 @@ static int update_file_flags(struct merge_options *o,\n \tif (update_wd) {\n \t\tenum object_type type;\n \t\tvoid *buf;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \n \t\tif (S_ISGITLINK(mode)) {\n \t\t\t/*\n@@ -3005,7 +3005,7 @@ static int read_oid_strbuf(struct merge_options *o,\n {\n \tvoid *buf;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tbuf = repo_read_object_file(the_repository, oid, &type, &size);\n \tif (!buf)\n \t\treturn err(o, _(\"cannot read object %s\"), oid_to_hex(oid));\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 59cdf0e1bb..2f1b08d135 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -77,7 +77,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,\n \tconst struct object_id *value_oid;\n \tenum object_type type;\n \tchar *value;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tvalue_oid = get_note(&c->tree, key_oid);\n \tif (!value_oid)\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 659b4dcc69..e38b34aa1f 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -297,7 +297,7 @@ static void check_notes_merge_worktree(struct notes_merge_options *o)\n }\n \n static void write_buf_to_worktree(const struct object_id *obj,\n-\t\t\t\t  const char *buf, unsigned long size)\n+\t\t\t\t  const char *buf, size_t size)\n {\n \tint fd;\n \tchar *path = git_pathdup(NOTES_MERGE_WORKTREE \"/%s\", oid_to_hex(obj));\n@@ -326,7 +326,7 @@ static void write_note_to_worktree(const struct object_id *obj,\n \t\t\t\t   const struct object_id *note)\n {\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tvoid *buf = repo_read_object_file(the_repository, note, &type, &size);\n \n \tif (!buf)\ndiff --git a/notes.c b/notes.c\nindex 608e303438..9a03a72b56 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -791,7 +791,7 @@ int combine_notes_concatenate(struct object_id *cur_oid,\n \t\t\t      const struct object_id *new_oid)\n {\n \tchar *cur_msg = NULL, *new_msg = NULL, *buf;\n-\tunsigned long cur_len, new_len, buf_len;\n+\tsize_t cur_len, new_len, buf_len;\n \tenum object_type cur_type, new_type;\n \tint ret;\n \n@@ -854,7 +854,7 @@ static int string_list_add_note_lines(struct string_list *list,\n \t\t\t\t      const struct object_id *oid)\n {\n \tchar *data;\n-\tunsigned long len;\n+\tsize_t len;\n \tenum object_type t;\n \n \tif (is_null_oid(oid))\n@@ -1208,7 +1208,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid\n \tstatic const char utf8[] = \"utf-8\";\n \tconst struct object_id *oid;\n \tchar *msg, *msg_p;\n-\tunsigned long linelen, msglen;\n+\tsize_t linelen, msglen;\n \tenum object_type type;\n \n \tif (!t)\ndiff --git a/object-store.h b/object-store.h\nindex 8dceed0f31..886c81d9c8 100644\n--- a/object-store.h\n+++ b/object-store.h\n@@ -155,16 +155,16 @@ void raw_object_store_clear(struct raw_object_store *o);\n  */\n const char *loose_object_path(struct repository *r, struct strbuf *buf, const unsigned char *sha1);\n \n-void *map_sha1_file(struct repository *r, const unsigned char *sha1, unsigned long *size);\n+void *map_sha1_file(struct repository *r, const unsigned char *sha1, size_t *size);\n \n extern void *read_object_file_extended(struct repository *r,\n \t\t\t\t       const struct object_id *oid,\n \t\t\t\t       enum object_type *type,\n-\t\t\t\t       unsigned long *size, int lookup_replace);\n+\t\t\t\t       size_t *size, int lookup_replace);\n static inline void *repo_read_object_file(struct repository *r,\n \t\t\t\t\t  const struct object_id *oid,\n \t\t\t\t\t  enum object_type *type,\n-\t\t\t\t\t  unsigned long *size)\n+\t\t\t\t\t  size_t *size)\n {\n \treturn read_object_file_extended(r, oid, type, size, 1);\n }\n@@ -173,19 +173,19 @@ static inline void *repo_read_object_file(struct repository *r,\n #endif\n \n /* Read and unpack an object file into memory, write memory to an object file */\n-int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);\n+int oid_object_info(struct repository *r, const struct object_id *, size_t *);\n \n-extern int hash_object_file(const void *buf, unsigned long len,\n+extern int hash_object_file(const void *buf, size_t len,\n \t\t\t    const char *type, struct object_id *oid);\n \n-extern int write_object_file(const void *buf, unsigned long len,\n+extern int write_object_file(const void *buf, size_t len,\n \t\t\t     const char *type, struct object_id *oid);\n \n-extern int hash_object_file_literally(const void *buf, unsigned long len,\n+extern int hash_object_file_literally(const void *buf, size_t len,\n \t\t\t\t      const char *type, struct object_id *oid,\n \t\t\t\t      unsigned flags);\n \n-extern int pretend_object_file(void *, unsigned long, enum object_type,\n+extern int pretend_object_file(void *, size_t, enum object_type,\n \t\t\t       struct object_id *oid);\n \n extern int force_object_loose(const struct object_id *oid, time_t mtime);\n@@ -200,7 +200,7 @@ extern int force_object_loose(const struct object_id *oid, time_t mtime);\n int read_loose_object(const char *path,\n \t\t      const struct object_id *expected_oid,\n \t\t      enum object_type *type,\n-\t\t      unsigned long *size,\n+\t\t      size_t *size,\n \t\t      void **contents);\n \n /*\n@@ -242,7 +242,7 @@ extern void assert_oid_type(const struct object_id *oid, enum object_type expect\n struct object_info {\n \t/* Request */\n \tenum object_type *typep;\n-\tunsigned long *sizep;\n+\tsize_t *sizep;\n \toff_t *disk_sizep;\n \tunsigned char *delta_base_sha1;\n \tstruct strbuf *type_name;\ndiff --git a/object.c b/object.c\nindex c29a97a7e9..ad8c09c041 100644\n--- a/object.c\n+++ b/object.c\n@@ -186,7 +186,7 @@ struct object *lookup_unknown_object(const unsigned char *sha1)\n \treturn obj;\n }\n \n-struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)\n+struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, size_t size, void *buffer, int *eaten_p)\n {\n \tstruct object *obj;\n \t*eaten_p = 0;\n@@ -248,7 +248,7 @@ struct object *parse_object_or_die(const struct object_id *oid,\n \n struct object *parse_object(struct repository *r, const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tint eaten;\n \tconst struct object_id *repl = lookup_replace_object(r, oid);\ndiff --git a/object.h b/object.h\nindex 796792cb32..b97a625882 100644\n--- a/object.h\n+++ b/object.h\n@@ -140,7 +140,7 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name\n  * parsing it.  eaten_p indicates if the object has a borrowed copy\n  * of buffer and the caller should not free() it.\n  */\n-struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);\n+struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, size_t size, void *buffer, int *eaten_p);\n \n /** Returns the object, with potentially excess memory allocated. **/\n struct object *lookup_unknown_object(const unsigned  char *sha1);\ndiff --git a/pack-check.c b/pack-check.c\nindex 4ff725a89c..b86a5e17b5 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -108,7 +108,7 @@ static int verify_packfile(struct repository *r,\n \tfor (i = 0; i < nr_objects; i++) {\n \t\tvoid *data;\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\toff_t curpos;\n \t\tint data_valid;\n \ndiff --git a/pack-objects.h b/pack-objects.h\nindex 3fda9da83a..24937553bb 100644\n--- a/pack-objects.h\n+++ b/pack-objects.h\n@@ -320,9 +320,9 @@ static inline void oe_set_delta_sibling(struct packing_data *pack,\n \t\te->delta_sibling_idx = 0;\n }\n \n-unsigned long oe_get_size_slow(struct packing_data *pack,\n+size_t oe_get_size_slow(struct packing_data *pack,\n \t\t\t       const struct object_entry *e);\n-static inline unsigned long oe_size(struct packing_data *pack,\n+static inline size_t oe_size(struct packing_data *pack,\n \t\t\t\t    const struct object_entry *e)\n {\n \tif (e->size_valid)\n@@ -333,7 +333,7 @@ static inline unsigned long oe_size(struct packing_data *pack,\n \n static inline int oe_size_less_than(struct packing_data *pack,\n \t\t\t\t    const struct object_entry *lhs,\n-\t\t\t\t    unsigned long rhs)\n+\t\t\t\t    size_t rhs)\n {\n \tif (lhs->size_valid)\n \t\treturn lhs->size_ < rhs;\n@@ -344,7 +344,7 @@ static inline int oe_size_less_than(struct packing_data *pack,\n \n static inline int oe_size_greater_than(struct packing_data *pack,\n \t\t\t\t       const struct object_entry *lhs,\n-\t\t\t\t       unsigned long rhs)\n+\t\t\t\t       size_t rhs)\n {\n \tif (lhs->size_valid)\n \t\treturn lhs->size_ > rhs;\n@@ -355,7 +355,7 @@ static inline int oe_size_greater_than(struct packing_data *pack,\n \n static inline void oe_set_size(struct packing_data *pack,\n \t\t\t       struct object_entry *e,\n-\t\t\t       unsigned long size)\n+\t\t\t       size_t size)\n {\n \tif (size < pack->oe_size_limit) {\n \t\te->size_ = size;\n@@ -367,7 +367,7 @@ static inline void oe_set_size(struct packing_data *pack,\n \t}\n }\n \n-static inline unsigned long oe_delta_size(struct packing_data *pack,\n+static inline size_t oe_delta_size(struct packing_data *pack,\n \t\t\t\t\t  const struct object_entry *e)\n {\n \tif (e->delta_size_valid)\n@@ -386,7 +386,7 @@ static inline unsigned long oe_delta_size(struct packing_data *pack,\n \n static inline void oe_set_delta_size(struct packing_data *pack,\n \t\t\t\t     struct object_entry *e,\n-\t\t\t\t     unsigned long size)\n+\t\t\t\t     size_t size)\n {\n \tif (size < pack->oe_delta_size_limit) {\n \t\te->delta_size_ = size;\ndiff --git a/pack.h b/pack.h\nindex da99fdd1d2..6f61f83485 100644\n--- a/pack.h\n+++ b/pack.h\n@@ -77,7 +77,7 @@ struct pack_idx_entry {\n \n struct progress;\n /* Note, the data argument could be NULL if object type is blob */\n-typedef int (*verify_fn)(const struct object_id *, enum object_type, unsigned long, void*, int*);\n+typedef int (*verify_fn)(const struct object_id *, enum object_type, size_t, void*, int*);\n \n extern const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, const struct pack_idx_option *, const unsigned char *sha1);\n extern int check_pack_crc(struct packed_git *p, struct pack_window **w_curs, off_t offset, off_t len, unsigned int nr);\ndiff --git a/packfile.c b/packfile.c\nindex 373adbc8a6..672b6aca4a 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -163,8 +163,8 @@ int load_idx(const char *path, const unsigned int hashsz, void *idx_map,\n \t\t * variable sized table containing 8-byte entries\n \t\t * for offsets larger than 2^31.\n \t\t */\n-\t\tunsigned long min_size = 8 + 4*256 + nr*(hashsz + 4 + 4) + hashsz + hashsz;\n-\t\tunsigned long max_size = min_size;\n+\t\tsize_t min_size = 8 + 4*256 + nr*(hashsz + 4 + 4) + hashsz + hashsz;\n+\t\tsize_t max_size = min_size;\n \t\tif (nr)\n \t\t\tmax_size += (nr - 1)*8;\n \t\tif (idx_size < min_size || idx_size > max_size)\n@@ -1047,12 +1047,12 @@ struct list_head *get_packed_git_mru(struct repository *r)\n \treturn &r->objects->packed_git_mru;\n }\n \n-unsigned long unpack_object_header_buffer(const unsigned char *buf,\n-\t\tunsigned long len, enum object_type *type, unsigned long *sizep)\n+size_t unpack_object_header_buffer(const unsigned char *buf,\n+\t\tsize_t len, enum object_type *type, size_t *sizep)\n {\n \tunsigned shift;\n-\tunsigned long size, c;\n-\tunsigned long used = 0;\n+\tsize_t size, c;\n+\tsize_t used = 0;\n \n \tc = buf[used++];\n \t*type = (c >> 4) & 7;\n@@ -1072,7 +1072,7 @@ unsigned long unpack_object_header_buffer(const unsigned char *buf,\n \treturn used;\n }\n \n-unsigned long get_size_from_delta(struct packed_git *p,\n+size_t get_size_from_delta(struct packed_git *p,\n \t\t\t\t  struct pack_window **w_curs,\n \t\t\t\t  off_t curpos)\n {\n@@ -1114,11 +1114,11 @@ unsigned long get_size_from_delta(struct packed_git *p,\n int unpack_object_header(struct packed_git *p,\n \t\t\t struct pack_window **w_curs,\n \t\t\t off_t *curpos,\n-\t\t\t unsigned long *sizep)\n+\t\t\t size_t *sizep)\n {\n \tunsigned char *base;\n \tsize_t left;\n-\tunsigned long used;\n+\tsize_t used;\n \tenum object_type type;\n \n \t/* use_pack() assures us we have [base, base + 20) available\n@@ -1269,7 +1269,7 @@ static enum object_type packed_to_object_type(struct repository *r,\n \n \twhile (type == OBJ_OFS_DELTA || type == OBJ_REF_DELTA) {\n \t\toff_t base_offset;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\t/* Push the object we're going to leave behind */\n \t\tif (poi_stack_nr >= poi_stack_alloc && poi_stack == small_poi_stack) {\n \t\t\tpoi_stack_alloc = alloc_nr(poi_stack_nr);\n@@ -1339,7 +1339,7 @@ struct delta_base_cache_entry {\n \tstruct delta_base_cache_key key;\n \tstruct list_head lru;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n };\n \n@@ -1404,7 +1404,7 @@ static void detach_delta_base_cache_entry(struct delta_base_cache_entry *ent)\n }\n \n static void *cache_or_unpack_entry(struct repository *r, struct packed_git *p,\n-\t\t\t\t   off_t base_offset, unsigned long *base_size,\n+\t\t\t\t   off_t base_offset, size_t *base_size,\n \t\t\t\t   enum object_type *type)\n {\n \tstruct delta_base_cache_entry *ent;\n@@ -1437,7 +1437,7 @@ void clear_delta_base_cache(void)\n }\n \n static void add_delta_base_cache(struct packed_git *p, off_t base_offset,\n-\tvoid *base, unsigned long base_size, enum object_type type)\n+\tvoid *base, size_t base_size, enum object_type type)\n {\n \tstruct delta_base_cache_entry *ent = xmalloc(sizeof(*ent));\n \tstruct list_head *lru, *tmp;\n@@ -1469,7 +1469,7 @@ int packed_object_info(struct repository *r, struct packed_git *p,\n \t\t       off_t obj_offset, struct object_info *oi)\n {\n \tstruct pack_window *w_curs = NULL;\n-\tunsigned long size;\n+\tsize_t size;\n \toff_t curpos = obj_offset;\n \tenum object_type type;\n \n@@ -1554,7 +1554,7 @@ int packed_object_info(struct repository *r, struct packed_git *p,\n static void *unpack_compressed_entry(struct packed_git *p,\n \t\t\t\t    struct pack_window **w_curs,\n \t\t\t\t    off_t curpos,\n-\t\t\t\t    unsigned long size)\n+\t\t\t\t    size_t size)\n {\n \tint st;\n \tgit_zstream stream;\n@@ -1601,13 +1601,13 @@ int do_check_packed_object_crc;\n struct unpack_entry_stack_ent {\n \toff_t obj_offset;\n \toff_t curpos;\n-\tunsigned long size;\n+\tsize_t size;\n };\n \n static void *read_object(struct repository *r,\n \t\t\t const struct object_id *oid,\n \t\t\t enum object_type *type,\n-\t\t\t unsigned long *size)\n+\t\t\t size_t *size)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tvoid *content;\n@@ -1621,12 +1621,12 @@ static void *read_object(struct repository *r,\n }\n \n void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,\n-\t\t   enum object_type *final_type, unsigned long *final_size)\n+\t\t   enum object_type *final_type, size_t *final_size)\n {\n \tstruct pack_window *w_curs = NULL;\n \toff_t curpos = obj_offset;\n \tvoid *data = NULL;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tstruct unpack_entry_stack_ent small_delta_stack[UNPACK_ENTRY_STACK_PREALLOC];\n \tstruct unpack_entry_stack_ent *delta_stack = small_delta_stack;\n@@ -1726,7 +1726,7 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,\n \t\tvoid *delta_data;\n \t\tvoid *base = data;\n \t\tvoid *external_base = NULL;\n-\t\tunsigned long delta_size, base_size = size;\n+\t\tsize_t delta_size, base_size = size;\n \t\tint i;\n \n \t\tdata = NULL;\ndiff --git a/packfile.h b/packfile.h\nindex 7384b4a201..25459f7e96 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -131,10 +131,10 @@ extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t n);\n extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *);\n \n extern int is_pack_valid(struct packed_git *);\n-extern void *unpack_entry(struct repository *r, struct packed_git *, off_t, enum object_type *, unsigned long *);\n-extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);\n-extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);\n-extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);\n+extern void *unpack_entry(struct repository *r, struct packed_git *, off_t, enum object_type *, size_t *);\n+extern size_t unpack_object_header_buffer(const unsigned char *buf, size_t len, enum object_type *type, size_t *sizep);\n+extern size_t get_size_from_delta(struct packed_git *, struct pack_window **, off_t);\n+extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, size_t *);\n \n extern void release_pack_memory(size_t);\n \ndiff --git a/patch-delta.c b/patch-delta.c\nindex b5c8594db6..42199fa956 100644\n--- a/patch-delta.c\n+++ b/patch-delta.c\n@@ -12,13 +12,13 @@\n #include \"git-compat-util.h\"\n #include \"delta.h\"\n \n-void *patch_delta(const void *src_buf, unsigned long src_size,\n-\t\t  const void *delta_buf, unsigned long delta_size,\n-\t\t  unsigned long *dst_size)\n+void *patch_delta(const void *src_buf, size_t src_size,\n+\t\t  const void *delta_buf, size_t delta_size,\n+\t\t  size_t *dst_size)\n {\n \tconst unsigned char *data, *top;\n \tunsigned char *dst_buf, *out, cmd;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tif (delta_size < DELTA_SIZE_MIN)\n \t\treturn NULL;\ndiff --git a/range-diff.c b/range-diff.c\nindex 767af8c5bb..dcb189f40d 100644\n--- a/range-diff.c\n+++ b/range-diff.c\n@@ -192,7 +192,7 @@ static void find_exact_matches(struct string_list *a, struct string_list *b)\n \thashmap_free(&map, 0);\n }\n \n-static void diffsize_consume(void *data, char *line, unsigned long len)\n+static void diffsize_consume(void *data, char *line, size_t len)\n {\n \t(*(int *)data)++;\n }\ndiff --git a/read-cache.c b/read-cache.c\nindex 78121bd63c..c37809292e 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -229,7 +229,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)\n {\n \tint match = -1;\n \tvoid *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tstruct strbuf sb = STRBUF_INIT;\n \n@@ -1676,7 +1676,7 @@ int verify_index_checksum;\n /* Allow fsck to force verification of the cache entry order. */\n int verify_ce_order;\n \n-static int verify_hdr(const struct cache_header *hdr, unsigned long size)\n+static int verify_hdr(const struct cache_header *hdr, size_t size)\n {\n \tgit_hash_ctx c;\n \tunsigned char hash[GIT_MAX_RAWSZ];\n@@ -1700,7 +1700,7 @@ static int verify_hdr(const struct cache_header *hdr, unsigned long size)\n }\n \n static int read_index_extension(struct index_state *istate,\n-\t\t\t\tconst char *ext, const char *data, unsigned long sz)\n+\t\t\t\tconst char *ext, const char *data, size_t sz)\n {\n \tswitch (CACHE_EXT(ext)) {\n \tcase CACHE_EXT_TREE:\n@@ -1746,7 +1746,7 @@ int read_index(struct index_state *istate)\n static struct cache_entry *create_from_disk(struct mem_pool *ce_mem_pool,\n \t\t\t\t\t    unsigned int version,\n \t\t\t\t\t    struct ondisk_cache_entry *ondisk,\n-\t\t\t\t\t    unsigned long *ent_size,\n+\t\t\t\t\t    size_t *ent_size,\n \t\t\t\t\t    const struct cache_entry *previous_ce)\n {\n \tstruct cache_entry *ce;\n@@ -1937,13 +1937,13 @@ struct load_index_extensions\n \tstruct index_state *istate;\n \tconst char *mmap;\n \tsize_t mmap_size;\n-\tunsigned long src_offset;\n+\tsize_t src_offset;\n };\n \n static void *load_index_extensions(void *_data)\n {\n \tstruct load_index_extensions *p = _data;\n-\tunsigned long src_offset = p->src_offset;\n+\tsize_t src_offset = p->src_offset;\n \n \twhile (src_offset <= p->mmap_size - the_hash_algo->rawsz - 8) {\n \t\t/* After an array of active_nr index entries,\n@@ -1971,17 +1971,17 @@ static void *load_index_extensions(void *_data)\n  * A helper function that will load the specified range of cache entries\n  * from the memory mapped file and add them to the given index.\n  */\n-static unsigned long load_cache_entry_block(struct index_state *istate,\n+static size_t load_cache_entry_block(struct index_state *istate,\n \t\t\tstruct mem_pool *ce_mem_pool, int offset, int nr, const char *mmap,\n-\t\t\tunsigned long start_offset, const struct cache_entry *previous_ce)\n+\t\t\tsize_t start_offset, const struct cache_entry *previous_ce)\n {\n \tint i;\n-\tunsigned long src_offset = start_offset;\n+\tsize_t src_offset = start_offset;\n \n \tfor (i = offset; i < offset + nr; i++) {\n \t\tstruct ondisk_cache_entry *disk_ce;\n \t\tstruct cache_entry *ce;\n-\t\tunsigned long consumed;\n+\t\tsize_t consumed;\n \n \t\tdisk_ce = (struct ondisk_cache_entry *)(mmap + src_offset);\n \t\tce = create_from_disk(ce_mem_pool, istate->version, disk_ce, &consumed, previous_ce);\n@@ -1993,10 +1993,10 @@ static unsigned long load_cache_entry_block(struct index_state *istate,\n \treturn src_offset - start_offset;\n }\n \n-static unsigned long load_all_cache_entries(struct index_state *istate,\n-\t\t\tconst char *mmap, size_t mmap_size, unsigned long src_offset)\n+static size_t load_all_cache_entries(struct index_state *istate,\n+\t\t\tconst char *mmap, size_t mmap_size, size_t src_offset)\n {\n-\tunsigned long consumed;\n+\tsize_t consumed;\n \n \tif (istate->version == 4) {\n \t\tmem_pool_init(&istate->ce_mem_pool,\n@@ -2030,7 +2030,7 @@ struct load_cache_entries_thread_data\n \tstruct index_entry_offset_table *ieot;\n \tint ieot_start;\t\t/* starting index into the ieot array */\n \tint ieot_blocks;\t/* count of ieot entries to process */\n-\tunsigned long consumed;\t/* return # of bytes in index file processed */\n+\tsize_t consumed;\t/* return # of bytes in index file processed */\n };\n \n /*\n@@ -2051,12 +2051,12 @@ static void *load_cache_entries_thread(void *_data)\n \treturn NULL;\n }\n \n-static unsigned long load_cache_entries_threaded(struct index_state *istate, const char *mmap, size_t mmap_size,\n-\t\t\tunsigned long src_offset, int nr_threads, struct index_entry_offset_table *ieot)\n+static size_t load_cache_entries_threaded(struct index_state *istate, const char *mmap, size_t mmap_size,\n+\t\t\tsize_t src_offset, int nr_threads, struct index_entry_offset_table *ieot)\n {\n \tint i, offset, ieot_blocks, ieot_start, err;\n \tstruct load_cache_entries_thread_data *data;\n-\tunsigned long consumed = 0;\n+\tsize_t consumed = 0;\n \n \t/* a little sanity checking */\n \tif (istate->name_hash_initialized)\n@@ -2127,7 +2127,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)\n {\n \tint fd;\n \tstruct stat st;\n-\tunsigned long src_offset;\n+\tsize_t src_offset;\n \tconst struct cache_header *hdr;\n \tconst char *mmap;\n \tsize_t mmap_size;\n@@ -2414,7 +2414,7 @@ int index_has_changes(struct index_state *istate,\n \n #define WRITE_BUFFER_SIZE 8192\n static unsigned char write_buffer[WRITE_BUFFER_SIZE];\n-static unsigned long write_buffer_len;\n+static size_t write_buffer_len;\n \n static int ce_write_flush(git_hash_ctx *context, int fd)\n {\n@@ -2999,9 +2999,9 @@ static int write_split_index(struct index_state *istate,\n \n static const char *shared_index_expire = \"2.weeks.ago\";\n \n-static unsigned long get_shared_index_expire_date(void)\n+static size_t get_shared_index_expire_date(void)\n {\n-\tstatic unsigned long shared_index_expire_date;\n+\tstatic size_t shared_index_expire_date;\n \tstatic int shared_index_expire_date_prepared;\n \n \tif (!shared_index_expire_date_prepared) {\n@@ -3017,7 +3017,7 @@ static unsigned long get_shared_index_expire_date(void)\n static int should_delete_shared_index(const char *shared_index_path)\n {\n \tstruct stat st;\n-\tunsigned long expiration;\n+\tsize_t expiration;\n \n \t/* Check timestamp */\n \texpiration = get_shared_index_expire_date();\n@@ -3250,10 +3250,10 @@ int index_name_is_other(const struct index_state *istate, const char *name,\n }\n \n void *read_blob_data_from_index(const struct index_state *istate,\n-\t\t\t\tconst char *path, unsigned long *size)\n+\t\t\t\tconst char *path, size_t *size)\n {\n \tint pos, len;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tenum object_type type;\n \tvoid *data;\n \ndiff --git a/ref-filter.c b/ref-filter.c\nindex 8f6e55a10e..26a55fee98 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -68,7 +68,7 @@ struct refname_atom {\n static struct expand_data {\n \tstruct object_id oid;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \toff_t disk_size;\n \tstruct object_id delta_base_oid;\n \tvoid *content;\n@@ -938,7 +938,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct expand_\n }\n \n /* See grab_values */\n-static void grab_tag_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_tag_values(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tint i;\n \tstruct tag *tag = (struct tag *) obj;\n@@ -960,7 +960,7 @@ static void grab_tag_values(struct atom_value *val, int deref, struct object *ob\n }\n \n /* See grab_values */\n-static void grab_commit_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_commit_values(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tint i;\n \tstruct commit *commit = (struct commit *) obj;\n@@ -993,7 +993,7 @@ static void grab_commit_values(struct atom_value *val, int deref, struct object\n \t}\n }\n \n-static const char *find_wholine(const char *who, int wholen, const char *buf, unsigned long sz)\n+static const char *find_wholine(const char *who, int wholen, const char *buf, size_t sz)\n {\n \tconst char *eol;\n \twhile (*buf) {\n@@ -1039,7 +1039,7 @@ static const char *copy_email(const char *buf)\n \treturn xmemdupz(email, eoemail + 1 - email);\n }\n \n-static char *copy_subject(const char *buf, unsigned long len)\n+static char *copy_subject(const char *buf, size_t len)\n {\n \tchar *r = xmemdupz(buf, len);\n \tint i;\n@@ -1089,7 +1089,7 @@ static void grab_date(const char *buf, struct atom_value *v, const char *atomnam\n }\n \n /* See grab_values */\n-static void grab_person(const char *who, struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_person(const char *who, struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tint i;\n \tint wholen = strlen(who);\n@@ -1148,11 +1148,11 @@ static void grab_person(const char *who, struct atom_value *val, int deref, stru\n \t}\n }\n \n-static void find_subpos(const char *buf, unsigned long sz,\n-\t\t\tconst char **sub, unsigned long *sublen,\n-\t\t\tconst char **body, unsigned long *bodylen,\n-\t\t\tunsigned long *nonsiglen,\n-\t\t\tconst char **sig, unsigned long *siglen)\n+static void find_subpos(const char *buf, size_t sz,\n+\t\t\tconst char **sub, size_t *sublen,\n+\t\t\tconst char **body, size_t *bodylen,\n+\t\t\tsize_t *nonsiglen,\n+\t\t\tconst char **sig, size_t *siglen)\n {\n \tconst char *eol;\n \t/* skip past header until we hit empty line */\n@@ -1196,7 +1196,7 @@ static void find_subpos(const char *buf, unsigned long sz,\n  * If 'lines' is greater than 0, append that many lines from the given\n  * 'buf' of length 'size' to the given strbuf.\n  */\n-static void append_lines(struct strbuf *out, const char *buf, unsigned long size, int lines)\n+static void append_lines(struct strbuf *out, const char *buf, size_t size, int lines)\n {\n \tint i;\n \tconst char *sp, *eol;\n@@ -1217,11 +1217,11 @@ static void append_lines(struct strbuf *out, const char *buf, unsigned long size\n }\n \n /* See grab_values */\n-static void grab_sub_body_contents(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_sub_body_contents(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tint i;\n \tconst char *subpos = NULL, *bodypos = NULL, *sigpos = NULL;\n-\tunsigned long sublen = 0, bodylen = 0, nonsiglen = 0, siglen = 0;\n+\tsize_t sublen = 0, bodylen = 0, nonsiglen = 0, siglen = 0;\n \n \tfor (i = 0; i < used_atom_cnt; i++) {\n \t\tstruct used_atom *atom = &used_atom[i];\n@@ -1290,7 +1290,7 @@ static void fill_missing_values(struct atom_value *val)\n  * pointed at by the ref itself; otherwise it is the object the\n  * ref (which is a tag) refers to.\n  */\n-static void grab_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_values(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tswitch (obj->type) {\n \tcase OBJ_TAG:\ndiff --git a/remote-testsvn.c b/remote-testsvn.c\nindex c846c9ee3b..df0f4c2445 100644\n--- a/remote-testsvn.c\n+++ b/remote-testsvn.c\n@@ -56,7 +56,7 @@ static char *read_ref_note(const struct object_id *oid)\n {\n \tconst struct object_id *note_oid;\n \tchar *msg = NULL;\n-\tunsigned long msglen;\n+\tsize_t msglen;\n \tenum object_type type;\n \n \tinit_notes(NULL, notes_ref, NULL, 0);\n@@ -105,7 +105,7 @@ static int note2mark_cb(const struct object_id *object_oid,\n {\n \tFILE *file = (FILE *)cb_data;\n \tchar *msg;\n-\tunsigned long msglen;\n+\tsize_t msglen;\n \tenum object_type type;\n \tstruct rev_note note;\n \ndiff --git a/rerere.c b/rerere.c\nindex b2a8e02f17..d7ade78357 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -973,7 +973,7 @@ static int handle_cache(struct index_state *istate,\n \n \twhile (pos < istate->cache_nr) {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \n \t\tce = istate->cache[pos++];\n \t\tif (ce_namelen(ce) != len || memcmp(ce->name, path, len))\ndiff --git a/sha1-file.c b/sha1-file.c\nindex 803c47e2fd..50d64c9d2b 100644\n--- a/sha1-file.c\n+++ b/sha1-file.c\n@@ -200,7 +200,7 @@ static struct cached_object {\n \tstruct object_id oid;\n \tenum object_type type;\n \tvoid *buf;\n-\tunsigned long size;\n+\tsize_t size;\n } *cached_objects;\n static int cached_object_nr, cached_object_alloc;\n \n@@ -871,7 +871,7 @@ void *xmmap(void *start, size_t length,\n  * the streaming interface and rehash it to do the same.\n  */\n int check_object_signature(const struct object_id *oid, void *map,\n-\t\t\t   unsigned long size, const char *type)\n+\t\t\t   size_t size, const char *type)\n {\n \tstruct object_id real_oid;\n \tenum object_type obj_type;\n@@ -1012,7 +1012,7 @@ static int quick_has_loose(struct repository *r,\n  * searching for a loose object named \"sha1\".\n  */\n static void *map_sha1_file_1(struct repository *r, const char *path,\n-\t\t\t     const unsigned char *sha1, unsigned long *size)\n+\t\t\t     const unsigned char *sha1, size_t *size)\n {\n \tvoid *map;\n \tint fd;\n@@ -1040,14 +1040,14 @@ static void *map_sha1_file_1(struct repository *r, const char *path,\n }\n \n void *map_sha1_file(struct repository *r,\n-\t\t    const unsigned char *sha1, unsigned long *size)\n+\t\t    const unsigned char *sha1, size_t *size)\n {\n \treturn map_sha1_file_1(r, NULL, sha1, size);\n }\n \n static int unpack_sha1_short_header(git_zstream *stream,\n-\t\t\t\t    unsigned char *map, unsigned long mapsize,\n-\t\t\t\t    void *buffer, unsigned long bufsiz)\n+\t\t\t\t    unsigned char *map, size_t mapsize,\n+\t\t\t\t    void *buffer, size_t bufsiz)\n {\n \t/* Get the data stream */\n \tmemset(stream, 0, sizeof(*stream));\n@@ -1061,8 +1061,8 @@ static int unpack_sha1_short_header(git_zstream *stream,\n }\n \n int unpack_sha1_header(git_zstream *stream,\n-\t\t       unsigned char *map, unsigned long mapsize,\n-\t\t       void *buffer, unsigned long bufsiz)\n+\t\t       unsigned char *map, size_t mapsize,\n+\t\t       void *buffer, size_t bufsiz)\n {\n \tint status = unpack_sha1_short_header(stream, map, mapsize,\n \t\t\t\t\t      buffer, bufsiz);\n@@ -1077,8 +1077,8 @@ int unpack_sha1_header(git_zstream *stream,\n }\n \n static int unpack_sha1_header_to_strbuf(git_zstream *stream, unsigned char *map,\n-\t\t\t\t\tunsigned long mapsize, void *buffer,\n-\t\t\t\t\tunsigned long bufsiz, struct strbuf *header)\n+\t\t\t\t\tsize_t mapsize, void *buffer,\n+\t\t\t\t\tsize_t bufsiz, struct strbuf *header)\n {\n \tint status;\n \n@@ -1112,11 +1112,11 @@ static int unpack_sha1_header_to_strbuf(git_zstream *stream, unsigned char *map,\n \treturn -1;\n }\n \n-static void *unpack_sha1_rest(git_zstream *stream, void *buffer, unsigned long size, const unsigned char *sha1)\n+static void *unpack_sha1_rest(git_zstream *stream, void *buffer, size_t size, const unsigned char *sha1)\n {\n \tint bytes = strlen(buffer) + 1;\n \tunsigned char *buf = xmallocz(size);\n-\tunsigned long n;\n+\tsize_t n;\n \tint status = Z_OK;\n \n \tn = stream->total_out - bytes;\n@@ -1166,7 +1166,7 @@ static int parse_sha1_header_extended(const char *hdr, struct object_info *oi,\n \t\t\t       unsigned int flags)\n {\n \tconst char *type_buf = hdr;\n-\tunsigned long size;\n+\tsize_t size;\n \tint type, type_len = 0;\n \n \t/*\n@@ -1206,7 +1206,7 @@ static int parse_sha1_header_extended(const char *hdr, struct object_info *oi,\n \t\treturn -1;\n \tif (size) {\n \t\tfor (;;) {\n-\t\t\tunsigned long c = *hdr - '0';\n+\t\t\tsize_t c = *hdr - '0';\n \t\t\tif (c > 9)\n \t\t\t\tbreak;\n \t\t\thdr++;\n@@ -1223,7 +1223,7 @@ static int parse_sha1_header_extended(const char *hdr, struct object_info *oi,\n \treturn *hdr ? -1 : type;\n }\n \n-int parse_sha1_header(const char *hdr, unsigned long *sizep)\n+int parse_sha1_header(const char *hdr, size_t *sizep)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \n@@ -1236,12 +1236,12 @@ static int sha1_loose_object_info(struct repository *r,\n \t\t\t\t  struct object_info *oi, int flags)\n {\n \tint status = 0;\n-\tunsigned long mapsize;\n+\tsize_t mapsize;\n \tvoid *map;\n \tgit_zstream stream;\n \tchar hdr[MAX_HEADER_LEN];\n \tstruct strbuf hdrbuf = STRBUF_INIT;\n-\tunsigned long size_scratch;\n+\tsize_t size_scratch;\n \n \tif (oi->delta_base_sha1)\n \t\thashclr(oi->delta_base_sha1);\n@@ -1409,7 +1409,7 @@ int oid_object_info_extended(struct repository *r, const struct object_id *oid,\n /* returns enum object_type or negative */\n int oid_object_info(struct repository *r,\n \t\t    const struct object_id *oid,\n-\t\t    unsigned long *sizep)\n+\t\t    size_t *sizep)\n {\n \tenum object_type type;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n@@ -1425,7 +1425,7 @@ int oid_object_info(struct repository *r,\n static void *read_object(struct repository *r,\n \t\t\t const unsigned char *sha1,\n \t\t\t enum object_type *type,\n-\t\t\t unsigned long *size)\n+\t\t\t size_t *size)\n {\n \tstruct object_id oid;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n@@ -1441,7 +1441,7 @@ static void *read_object(struct repository *r,\n \treturn content;\n }\n \n-int pretend_object_file(void *buf, unsigned long len, enum object_type type,\n+int pretend_object_file(void *buf, size_t len, enum object_type type,\n \t\t\tstruct object_id *oid)\n {\n \tstruct cached_object *co;\n@@ -1467,7 +1467,7 @@ int pretend_object_file(void *buf, unsigned long len, enum object_type type,\n void *read_object_file_extended(struct repository *r,\n \t\t\t\tconst struct object_id *oid,\n \t\t\t\tenum object_type *type,\n-\t\t\t\tunsigned long *size,\n+\t\t\t\tsize_t *size,\n \t\t\t\tint lookup_replace)\n {\n \tvoid *data;\n@@ -1503,12 +1503,12 @@ void *read_object_file_extended(struct repository *r,\n \n void *read_object_with_reference(const struct object_id *oid,\n \t\t\t\t const char *required_type_name,\n-\t\t\t\t unsigned long *size,\n+\t\t\t\t size_t *size,\n \t\t\t\t struct object_id *actual_oid_return)\n {\n \tenum object_type type, required_type;\n \tvoid *buffer;\n-\tunsigned long isize;\n+\tsize_t isize;\n \tstruct object_id actual_oid;\n \n \trequired_type = type_from_string(required_type_name);\n@@ -1550,7 +1550,7 @@ void *read_object_with_reference(const struct object_id *oid,\n \t}\n }\n \n-static void write_object_file_prepare(const void *buf, unsigned long len,\n+static void write_object_file_prepare(const void *buf, size_t len,\n \t\t\t\t      const char *type, struct object_id *oid,\n \t\t\t\t      char *hdr, int *hdrlen)\n {\n@@ -1616,7 +1616,7 @@ static int write_buffer(int fd, const void *buf, size_t len)\n \treturn 0;\n }\n \n-int hash_object_file(const void *buf, unsigned long len, const char *type,\n+int hash_object_file(const void *buf, size_t len, const char *type,\n \t\t     struct object_id *oid)\n {\n \tchar hdr[MAX_HEADER_LEN];\n@@ -1680,7 +1680,7 @@ static int create_tmpfile(struct strbuf *tmp, const char *filename)\n }\n \n static int write_loose_object(const struct object_id *oid, char *hdr,\n-\t\t\t      int hdrlen, const void *buf, unsigned long len,\n+\t\t\t      int hdrlen, const void *buf, size_t len,\n \t\t\t      time_t mtime)\n {\n \tint fd, ret;\n@@ -1770,7 +1770,7 @@ static int freshen_packed_object(const struct object_id *oid)\n \treturn 1;\n }\n \n-int write_object_file(const void *buf, unsigned long len, const char *type,\n+int write_object_file(const void *buf, size_t len, const char *type,\n \t\t      struct object_id *oid)\n {\n \tchar hdr[MAX_HEADER_LEN];\n@@ -1785,7 +1785,7 @@ int write_object_file(const void *buf, unsigned long len, const char *type,\n \treturn write_loose_object(oid, hdr, hdrlen, buf, len, 0);\n }\n \n-int hash_object_file_literally(const void *buf, unsigned long len,\n+int hash_object_file_literally(const void *buf, size_t len,\n \t\t\t       const char *type, struct object_id *oid,\n \t\t\t       unsigned flags)\n {\n@@ -1811,7 +1811,7 @@ int hash_object_file_literally(const void *buf, unsigned long len,\n int force_object_loose(const struct object_id *oid, time_t mtime)\n {\n \tvoid *buf;\n-\tunsigned long len;\n+\tsize_t len;\n \tenum object_type type;\n \tchar hdr[MAX_HEADER_LEN];\n \tint hdrlen;\n@@ -2248,14 +2248,14 @@ void odb_load_loose_cache(struct object_directory *odb, int subdir_nr)\n \n static int check_stream_sha1(git_zstream *stream,\n \t\t\t     const char *hdr,\n-\t\t\t     unsigned long size,\n+\t\t\t     size_t size,\n \t\t\t     const char *path,\n \t\t\t     const unsigned char *expected_sha1)\n {\n \tgit_hash_ctx c;\n \tunsigned char real_sha1[GIT_MAX_RAWSZ];\n \tunsigned char buf[4096];\n-\tunsigned long total_read;\n+\tsize_t total_read;\n \tint status = Z_OK;\n \n \tthe_hash_algo->init_fn(&c);\n@@ -2307,12 +2307,12 @@ static int check_stream_sha1(git_zstream *stream,\n int read_loose_object(const char *path,\n \t\t      const struct object_id *expected_oid,\n \t\t      enum object_type *type,\n-\t\t      unsigned long *size,\n+\t\t      size_t *size,\n \t\t      void **contents)\n {\n \tint ret = -1;\n \tvoid *map = NULL;\n-\tunsigned long mapsize;\n+\tsize_t mapsize;\n \tgit_zstream stream;\n \tchar hdr[MAX_HEADER_LEN];\n \ndiff --git a/sha1dc_git.c b/sha1dc_git.c\nindex e0cc9d988c..b24fc9af55 100644\n--- a/sha1dc_git.c\n+++ b/sha1dc_git.c\n@@ -25,7 +25,7 @@ void git_SHA1DCFinal(unsigned char hash[20], SHA1_CTX *ctx)\n /*\n  * Same as SHA1DCUpdate, but adjust types to match git's usual interface.\n  */\n-void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, unsigned long len)\n+void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, size_t len)\n {\n \tconst char *data = vdata;\n \t/* We expect an unsigned long, but sha1dc only takes an int */\ndiff --git a/sha1dc_git.h b/sha1dc_git.h\nindex 41e1c3fd3f..847b38fb4b 100644\n--- a/sha1dc_git.h\n+++ b/sha1dc_git.h\n@@ -15,7 +15,7 @@ void git_SHA1DCInit(SHA1_CTX *);\n #endif\n \n void git_SHA1DCFinal(unsigned char [20], SHA1_CTX *);\n-void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, unsigned long len);\n+void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, size_t len);\n \n #define platform_SHA_CTX SHA1_CTX\n #define platform_SHA1_Init git_SHA1DCInit\ndiff --git a/streaming.c b/streaming.c\nindex 891f82f51a..1e7a656738 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -69,19 +69,19 @@ struct filtered_istream {\n \n struct git_istream {\n \tconst struct stream_vtbl *vtbl;\n-\tunsigned long size; /* inflated size of full object */\n+\tsize_t size; /* inflated size of full object */\n \tgit_zstream z;\n \tenum { z_unused, z_used, z_done, z_error } z_state;\n \n \tunion {\n \t\tstruct {\n \t\t\tchar *buf; /* from read_object() */\n-\t\t\tunsigned long read_ptr;\n+\t\t\tsize_t read_ptr;\n \t\t} incore;\n \n \t\tstruct {\n \t\t\tvoid *mapped;\n-\t\t\tunsigned long mapsize;\n+\t\t\tsize_t mapsize;\n \t\t\tchar hdr[32];\n \t\t\tint hdr_avail;\n \t\t\tint hdr_used;\n@@ -112,7 +112,7 @@ static enum input_source istream_source(const struct object_id *oid,\n \t\t\t\t\tenum object_type *type,\n \t\t\t\t\tstruct object_info *oi)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tint status;\n \n \toi->typep = type;\n@@ -135,7 +135,7 @@ static enum input_source istream_source(const struct object_id *oid,\n \n struct git_istream *open_istream(const struct object_id *oid,\n \t\t\t\t enum object_type *type,\n-\t\t\t\t unsigned long *size,\n+\t\t\t\t size_t *size,\n \t\t\t\t struct stream_filter *filter)\n {\n \tstruct git_istream *st;\n@@ -516,7 +516,7 @@ int stream_blob_to_fd(int fd, const struct object_id *oid, struct stream_filter\n {\n \tstruct git_istream *st;\n \tenum object_type type;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tssize_t kept = 0;\n \tint result = -1;\n \ndiff --git a/streaming.h b/streaming.h\nindex 32f4626771..552eb1d7c5 100644\n--- a/streaming.h\n+++ b/streaming.h\n@@ -8,7 +8,7 @@\n /* opaque */\n struct git_istream;\n \n-extern struct git_istream *open_istream(const struct object_id *, enum object_type *, unsigned long *, struct stream_filter *);\n+extern struct git_istream *open_istream(const struct object_id *, enum object_type *, size_t *, struct stream_filter *);\n extern int close_istream(struct git_istream *);\n extern ssize_t read_istream(struct git_istream *, void *, size_t);\n \ndiff --git a/submodule-config.c b/submodule-config.c\nindex 86737087ba..46172820b1 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -527,7 +527,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,\n \t\tenum lookup_type lookup_type)\n {\n \tstruct strbuf rev = STRBUF_INIT;\n-\tunsigned long config_size;\n+\tsize_t config_size;\n \tchar *config = NULL;\n \tstruct object_id oid;\n \tenum object_type type;\ndiff --git a/t/helper/test-delta.c b/t/helper/test-delta.c\nindex e749a49c88..b613cd0216 100644\n--- a/t/helper/test-delta.c\n+++ b/t/helper/test-delta.c\n@@ -21,7 +21,7 @@ int cmd__delta(int argc, const char **argv)\n \tint fd;\n \tstruct stat st;\n \tvoid *from_buf, *data_buf, *out_buf;\n-\tunsigned long from_size, data_size, out_size;\n+\tsize_t from_size, data_size, out_size;\n \n \tif (argc != 5 || (strcmp(argv[1], \"-d\") && strcmp(argv[1], \"-p\"))) {\n \t\tfprintf(stderr, \"usage: %s\\n\", usage_str);\ndiff --git a/tag.c b/tag.c\nindex 1ed43ec925..90502454a0 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -41,7 +41,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n {\n \tenum object_type type;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \ttype = oid_object_info(the_repository, oid, NULL);\n@@ -132,7 +132,7 @@ void release_tag_memory(struct tag *t)\n \tt->date = 0;\n }\n \n-int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, unsigned long size)\n+int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, size_t size)\n {\n \tstruct object_id oid;\n \tchar type[20];\n@@ -195,7 +195,7 @@ int parse_tag(struct tag *item)\n {\n \tenum object_type type;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \tif (item->object.parsed)\ndiff --git a/tag.h b/tag.h\nindex e669c3e497..b540b100ef 100644\n--- a/tag.h\n+++ b/tag.h\n@@ -12,7 +12,7 @@ struct tag {\n \ttimestamp_t date;\n };\n extern struct tag *lookup_tag(struct repository *r, const struct object_id *oid);\n-extern int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, unsigned long size);\n+extern int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, size_t size);\n extern int parse_tag(struct tag *item);\n extern void release_tag_memory(struct tag *t);\n extern struct object *deref_tag(struct repository *r, struct object *, const char *, int);\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 5709e910e0..a0079aecee 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -82,7 +82,7 @@ int init_tree_desc_gently(struct tree_desc *desc, const void *buffer, unsigned l\n \n void *fill_tree_descriptor(struct tree_desc *desc, const struct object_id *oid)\n {\n-\tunsigned long size = 0;\n+\tsize_t size = 0;\n \tvoid *buf = NULL;\n \n \tif (oid) {\n@@ -108,8 +108,8 @@ static int update_tree_entry_internal(struct tree_desc *desc, struct strbuf *err\n {\n \tconst void *buf = desc->buffer;\n \tconst unsigned char *end = desc->entry.oid->hash + the_hash_algo->rawsz;\n-\tunsigned long size = desc->size;\n-\tunsigned long len = end - (const unsigned char *)buf;\n+\tsize_t size = desc->size;\n+\tsize_t len = end - (const unsigned char *)buf;\n \n \tif (size < len)\n \t\tdie(_(\"too-short tree file\"));\n@@ -493,7 +493,7 @@ int traverse_trees(struct index_state *istate,\n \n struct dir_state {\n \tvoid *tree;\n-\tunsigned long size;\n+\tsize_t size;\n \tstruct object_id oid;\n };\n \n@@ -536,7 +536,7 @@ int get_tree_entry(const struct object_id *tree_oid, const char *name, struct ob\n {\n \tint retval;\n \tvoid *tree;\n-\tunsigned long size;\n+\tsize_t size;\n \tstruct object_id root;\n \n \ttree = read_object_with_reference(tree_oid, tree_type, &size, &root);\n@@ -605,7 +605,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(struct object_id *tre\n \t\tif (!t.buffer) {\n \t\t\tvoid *tree;\n \t\t\tstruct object_id root;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \t\t\ttree = read_object_with_reference(&current_tree_oid,\n \t\t\t\t\t\t\t  tree_type, &size,\n \t\t\t\t\t\t\t  &root);\n@@ -701,7 +701,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(struct object_id *tre\n \t\t\tgoto done;\n \t\t} else if (S_ISLNK(*mode)) {\n \t\t\t/* Follow a symlink */\n-\t\t\tunsigned long link_len;\n+\t\t\tsize_t link_len;\n \t\t\tsize_t len;\n \t\t\tchar *contents, *contents_start;\n \t\t\tstruct dir_state *parent;\ndiff --git a/tree.c b/tree.c\nindex 3e82bd67d2..0b599169ea 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -220,7 +220,7 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)\n {\n \t enum object_type type;\n \t void *buffer;\n-\t unsigned long size;\n+\t size_t size;\n \n \tif (item->object.parsed)\n \t\treturn 0;\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex fdf377df71..44546d4a1a 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -169,7 +169,7 @@ int read_mmfile(mmfile_t *ptr, const char *filename)\n \n void read_mmblob(mmfile_t *ptr, const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \n \tif (oideq(oid, &null_oid)) {\n@@ -185,7 +185,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid)\n }\n \n #define FIRST_FEW_BYTES 8000\n-int buffer_is_binary(const char *ptr, unsigned long size)\n+int buffer_is_binary(const char *ptr, size_t size)\n {\n \tif (FIRST_FEW_BYTES < size)\n \t\tsize = FIRST_FEW_BYTES;\ndiff --git a/xdiff-interface.h b/xdiff-interface.h\nindex 2d41fffd4c..6c99f8d047 100644\n--- a/xdiff-interface.h\n+++ b/xdiff-interface.h\n@@ -11,7 +11,7 @@\n  */\n #define MAX_XDIFF_SIZE (1024UL * 1024 * 1023)\n \n-typedef void (*xdiff_emit_line_fn)(void *, char *, unsigned long);\n+typedef void (*xdiff_emit_line_fn)(void *, char *, size_t);\n typedef void (*xdiff_emit_hunk_fn)(void *data,\n \t\t\t\t   long old_begin, long old_nr,\n \t\t\t\t   long new_begin, long new_nr,\n@@ -25,7 +25,7 @@ int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,\n \t\t  xpparam_t const *xpp, xdemitconf_t const *xecfg);\n int read_mmfile(mmfile_t *ptr, const char *filename);\n void read_mmblob(mmfile_t *ptr, const struct object_id *oid);\n-int buffer_is_binary(const char *ptr, unsigned long size);\n+int buffer_is_binary(const char *ptr, size_t size);\n \n extern void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line, int cflags);\n extern void xdiff_clear_find_func(xdemitconf_t *xecfg);\n-- \n2.19.0.271.gfe8321ec05\n\n"},{"id":"363698","messageId":"20181120051649.GA16814@tor.lan","threadId":"49862","inReplyTo":"20181120050454.16673-1-tboegi@web.de","subject":"Re: [PATCH/RFC v2 1/1] Use size_t instead of 'unsigned long' for data in memory","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2018-11-20T05:16:49Z","receivedAt":"2018-11-20T05:16:52Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Tue, Nov 20, 2018 at 06:04:54AM +0100, tboegi@web.de wrote:\n> From: Torsten Bögershausen <tboegi@web.de>\n> \n> Currently the length of data which is stored in memory is stored\n> in \"unsigned long\" at many places in the code base.\n> This is OK when both \"unsigned long\" and size_t are 32 bits,\n> (and is OK when both are 64 bits).\n> On a 64 bit Windows system am \"unsigned long\" is 32 bit, and\n> that may be too short to measure the size of objects in memory,\n> a size_t is the natural choice.\n> \n> Improve the code base in \"small steps\", as small as possible.\n> The smallest step seems to be much bigger than expected.\n\nOps, it seems as if I send this message out twice -\nplease ignore the \"PATCH/RFC v2 1/1\"\nSorry for the noise.\n"}]}