diff options
author | Vicent Martà <tanoku@gmail.com> | 2012-02-27 04:28:31 +0100 |
---|---|---|
committer | Vicent Martà <tanoku@gmail.com> | 2012-02-27 05:30:07 +0100 |
commit | 13224ea4aad9a1b3c9cc4c992ceaea9af623e047 (patch) | |
tree | b5c3a503d1ef7ba6269bf4291530c4e8e5936bdb /tests | |
parent | e07c2d225deec42e592133df49ad8c564d4d66c7 (diff) | |
download | libgit2-13224ea4aad9a1b3c9cc4c992ceaea9af623e047.tar.gz |
buffer: Unify `git_fbuffer` and `git_buf`
This makes so much sense that I can't believe it hasn't been done
before. Kill the old `git_fbuffer` and read files straight into
`git_buf` objects.
Also: In order to fully support 4GB files in 32-bit systems, the
`git_buf` implementation has been changed from using `ssize_t` for
storage and storing negative values on allocation failure, to using
`size_t` and changing the buffer pointer to a magical pointer on
allocation failure.
Hopefully this won't break anything.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_helpers.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/tests/test_helpers.c b/tests/test_helpers.c index 42c8031cd..837358453 100644 --- a/tests/test_helpers.c +++ b/tests/test_helpers.c @@ -182,7 +182,7 @@ int cmp_objects(git_rawobj *o, object_data *d) int copy_file(const char *src, const char *dst) { - git_fbuffer source_buf; + git_buf source_buf = GIT_BUF_INIT; git_file dst_fd; int error = GIT_ERROR; @@ -193,10 +193,10 @@ int copy_file(const char *src, const char *dst) if (dst_fd < 0) goto cleanup; - error = p_write(dst_fd, source_buf.data, source_buf.len); + error = p_write(dst_fd, source_buf.ptr, source_buf.size); cleanup: - git_futils_freebuffer(&source_buf); + git_buf_free(&source_buf); p_close(dst_fd); return error; @@ -204,22 +204,23 @@ cleanup: int cmp_files(const char *a, const char *b) { - git_fbuffer buf_a, buf_b; + git_buf buf_a = GIT_BUF_INIT; + git_buf buf_b = GIT_BUF_INIT; int error = GIT_ERROR; if (git_futils_readbuffer(&buf_a, a) < GIT_SUCCESS) return GIT_ERROR; if (git_futils_readbuffer(&buf_b, b) < GIT_SUCCESS) { - git_futils_freebuffer(&buf_a); + git_buf_free(&buf_a); return GIT_ERROR; } - if (buf_a.len == buf_b.len && !memcmp(buf_a.data, buf_b.data, buf_a.len)) + if (buf_a.size == buf_b.size && !memcmp(buf_a.ptr, buf_b.ptr, buf_a.size)) error = GIT_SUCCESS; - git_futils_freebuffer(&buf_a); - git_futils_freebuffer(&buf_b); + git_buf_free(&buf_a); + git_buf_free(&buf_b); return error; } |