diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2023-05-11 21:44:17 +0100 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2023-05-11 21:44:17 +0100 |
commit | 027630ddd42e5ab4f4f5a221f38a3fd5bda4e3d4 (patch) | |
tree | 88ed972824502635c4c77cdfd1b5429f1d6fab0c /deps/xdiff/xutils.c | |
parent | a821455ee430d28d0032b91ba89b414b4b724464 (diff) | |
download | libgit2-027630ddd42e5ab4f4f5a221f38a3fd5bda4e3d4.tar.gz |
xdiff: update to xdiff from git 2.40.1ethomson/xdiff
Diffstat (limited to 'deps/xdiff/xutils.c')
-rw-r--r-- | deps/xdiff/xutils.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/deps/xdiff/xutils.c b/deps/xdiff/xutils.c index cfa6e2220..9e36f2487 100644 --- a/deps/xdiff/xutils.c +++ b/deps/xdiff/xutils.c @@ -122,7 +122,7 @@ long xdl_guess_lines(mmfile_t *mf, long sample) { long nl = 0, size, tsize = 0; char const *data, *cur, *top; - if ((cur = data = xdl_mmfile_first(mf, &size)) != NULL) { + if ((cur = data = xdl_mmfile_first(mf, &size))) { for (top = data + size; nl < sample && cur < top; ) { nl++; if (!(cur = memchr(cur, '\n', top - cur))) @@ -432,3 +432,20 @@ int xdl_fall_back_diff(xdfenv_t *diff_env, xpparam_t const *xpp, return 0; } + +void* xdl_alloc_grow_helper(void *p, long nr, long *alloc, size_t size) +{ + void *tmp = NULL; + size_t n = ((LONG_MAX - 16) / 2 >= *alloc) ? 2 * *alloc + 16 : LONG_MAX; + if (nr > n) + n = nr; + if (SIZE_MAX / size >= n) + tmp = xdl_realloc(p, n * size); + if (tmp) { + *alloc = n; + } else { + xdl_free(p); + *alloc = 0; + } + return tmp; +} |