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/odb_mempack.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/odb_mempack.c')
-rw-r--r-- | src/odb_mempack.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/odb_mempack.c b/src/odb_mempack.c index a71d8db4b..32bc84442 100644 --- a/src/odb_mempack.c +++ b/src/odb_mempack.c @@ -38,6 +38,7 @@ static int impl__write(git_odb_backend *_backend, const git_oid *oid, const void struct memory_packer_db *db = (struct memory_packer_db *)_backend; struct memobject *obj = NULL; khiter_t pos; + size_t alloc_len; int rval; pos = kh_put(oid, db->objects, oid, &rval); @@ -47,8 +48,8 @@ static int impl__write(git_odb_backend *_backend, const git_oid *oid, const void if (rval == 0) return 0; - GITERR_CHECK_ALLOC_ADD(sizeof(struct memobject), len); - obj = git__malloc(sizeof(struct memobject) + len); + GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(struct memobject), len); + obj = git__malloc(alloc_len); GITERR_CHECK_ALLOC(obj); memcpy(obj->data, data, len); |