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 /src/repository.c | |
| 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 'src/repository.c')
| -rw-r--r-- | src/repository.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/repository.c b/src/repository.c index f394d06fe..c46dd9df9 100644 --- a/src/repository.c +++ b/src/repository.c @@ -467,7 +467,7 @@ static int retrieve_ceiling_directories_offset( */ static int read_gitfile(git_buf *path_out, const char *file_path, const char *base_path) { - git_fbuffer file; + git_buf file = GIT_BUF_INIT; int error; assert(path_out && file_path); @@ -476,22 +476,22 @@ static int read_gitfile(git_buf *path_out, const char *file_path, const char *ba if (error < GIT_SUCCESS) return error; - if (git__prefixcmp((char *)file.data, GIT_FILE_CONTENT_PREFIX)) { - git_futils_freebuffer(&file); + if (git__prefixcmp((char *)file.ptr, GIT_FILE_CONTENT_PREFIX)) { + git_buf_free(&file); return git__throw(GIT_ENOTFOUND, "Invalid gitfile format `%s`", file_path); } - git_futils_fbuffer_rtrim(&file); + git_buf_rtrim(&file); - if (strlen(GIT_FILE_CONTENT_PREFIX) == file.len) { - git_futils_freebuffer(&file); + if (strlen(GIT_FILE_CONTENT_PREFIX) == file.size) { + git_buf_free(&file); return git__throw(GIT_ENOTFOUND, "No path in git file `%s`", file_path); } error = git_path_prettify_dir(path_out, - ((char *)file.data) + strlen(GIT_FILE_CONTENT_PREFIX), base_path); + ((char *)file.ptr) + strlen(GIT_FILE_CONTENT_PREFIX), base_path); - git_futils_freebuffer(&file); + git_buf_free(&file); if (error == GIT_SUCCESS && git_path_exists(path_out->ptr) == 0) return GIT_SUCCESS; |
