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/sortedcache.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/sortedcache.c')
-rw-r--r-- | src/sortedcache.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/sortedcache.c b/src/sortedcache.c index 021f79632..1195ea339 100644 --- a/src/sortedcache.c +++ b/src/sortedcache.c @@ -11,13 +11,13 @@ int git_sortedcache_new( const char *path) { git_sortedcache *sc; - size_t pathlen; + size_t pathlen, alloclen; pathlen = path ? strlen(path) : 0; - GITERR_CHECK_ALLOC_ADD(sizeof(git_sortedcache), pathlen); - GITERR_CHECK_ALLOC_ADD(sizeof(git_sortedcache) + pathlen, 1); - sc = git__calloc(1, sizeof(git_sortedcache) + pathlen + 1); + GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_sortedcache), pathlen); + GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); + sc = git__calloc(1, alloclen); GITERR_CHECK_ALLOC(sc); if (git_pool_init(&sc->pool, 1, 0) < 0 || |