diff options
author | Edward Thomson <ethomson@microsoft.com> | 2015-02-12 12:19:37 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2015-02-13 09:27:33 -0500 |
commit | f1453c59b2afb9dab43281bfe9f1ba34cf6e0d02 (patch) | |
tree | cb189e211547042080f35227b7e4d3f9b0c8ac2a /src/blame_git.c | |
parent | 650e45f69124bd8b53ecefddeb214a82538ab2c1 (diff) | |
download | libgit2-f1453c59b2afb9dab43281bfe9f1ba34cf6e0d02.tar.gz |
Make our overflow check look more like gcc/clang's
Make our overflow checking look more like gcc and clang's, so that
we can substitute it out with the compiler instrinsics on platforms
that support it. This means dropping the ability to pass `NULL` as
an out parameter.
As a result, the macros also get updated to reflect this as well.
Diffstat (limited to 'src/blame_git.c')
-rw-r--r-- | src/blame_git.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/blame_git.c b/src/blame_git.c index 05aef5d99..e863efe2e 100644 --- a/src/blame_git.c +++ b/src/blame_git.c @@ -36,14 +36,14 @@ static void origin_decref(git_blame__origin *o) static int make_origin(git_blame__origin **out, git_commit *commit, const char *path) { git_blame__origin *o; - size_t path_len = strlen(path); + size_t path_len = strlen(path), alloc_len; int error = 0; - GITERR_CHECK_ALLOC_ADD(sizeof(*o), path_len); - GITERR_CHECK_ALLOC_ADD(sizeof(*o) + path_len, 1); - - o = git__calloc(1, sizeof(*o) + path_len + 1); + GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(*o), path_len); + GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 1); + o = git__calloc(1, alloc_len); GITERR_CHECK_ALLOC(o); + o->commit = commit; o->refcnt = 1; strcpy(o->path, path); |