odb: use `git_object_size_t` for object size Instead of using a signed type (`off_t`) use a new `git_object_size_t` for the sizes of objects.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
diff --git a/include/git2/odb.h b/include/git2/odb.h
index e8824b7..c4bfa52 100644
--- a/include/git2/odb.h
+++ b/include/git2/odb.h
@@ -294,7 +294,7 @@ GIT_EXTERN(int) git_odb_write(git_oid *out, git_odb *odb, const void *data, size
* @param type type of the object that will be written
* @return 0 if the stream was created; error code otherwise
*/
-GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **out, git_odb *db, git_off_t size, git_object_t type);
+GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **out, git_odb *db, git_object_size_t size, git_object_t type);
/**
* Write to an odb stream
diff --git a/include/git2/odb_backend.h b/include/git2/odb_backend.h
index 47e0dd4..c593bac 100644
--- a/include/git2/odb_backend.h
+++ b/include/git2/odb_backend.h
@@ -87,8 +87,8 @@ struct git_odb_stream {
unsigned int mode;
void *hash_ctx;
- git_off_t declared_size;
- git_off_t received_bytes;
+ git_object_size_t declared_size;
+ git_object_size_t received_bytes;
/**
* Write at most `len` bytes into `buffer` and advance the stream.
diff --git a/src/odb.c b/src/odb.c
index 06e4930..2998a2d 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -89,7 +89,7 @@ int git_odb__format_object_header(
size_t *written,
char *hdr,
size_t hdr_size,
- git_off_t obj_len,
+ git_object_size_t obj_len,
git_object_t obj_type)
{
const char *type_str = git_object_type2string(obj_type);
@@ -320,7 +320,7 @@ int git_odb__hashlink(git_oid *out, const char *path)
int git_odb_hashfile(git_oid *out, const char *path, git_object_t type)
{
- git_off_t size;
+ git_object_size_t size;
int result, fd = git_futils_open_ro(path);
if (fd < 0)
return fd;
@@ -385,7 +385,7 @@ static void fake_wstream__free(git_odb_stream *_stream)
git__free(stream);
}
-static int init_fake_wstream(git_odb_stream **stream_p, git_odb_backend *backend, git_off_t size, git_object_t type)
+static int init_fake_wstream(git_odb_stream **stream_p, git_odb_backend *backend, git_object_size_t size, git_object_t type)
{
fake_wstream *stream;
size_t blobsize;
@@ -1319,7 +1319,7 @@ int git_odb_write(
return error;
}
-static int hash_header(git_hash_ctx *ctx, git_off_t size, git_object_t type)
+static int hash_header(git_hash_ctx *ctx, git_object_size_t size, git_object_t type)
{
char header[64];
size_t hdrlen;
@@ -1333,7 +1333,7 @@ static int hash_header(git_hash_ctx *ctx, git_off_t size, git_object_t type)
}
int git_odb_open_wstream(
- git_odb_stream **stream, git_odb *db, git_off_t size, git_object_t type)
+ git_odb_stream **stream, git_odb *db, git_object_size_t size, git_object_t type)
{
size_t i, writes = 0;
int error = GIT_ERROR;
diff --git a/src/odb.h b/src/odb.h
index 79ed6b4..8dd4efd 100644
--- a/src/odb.h
+++ b/src/odb.h
@@ -70,7 +70,7 @@ int git_odb__hashobj(git_oid *id, git_rawobj *obj);
/*
* Format the object header such as it would appear in the on-disk object
*/
-int git_odb__format_object_header(size_t *out_len, char *hdr, size_t hdr_size, git_off_t obj_len, git_object_t obj_type);
+int git_odb__format_object_header(size_t *out_len, char *hdr, size_t hdr_size, git_object_size_t obj_len, git_object_t obj_type);
/*
* Hash an open file descriptor.