summaryrefslogtreecommitdiff
path: root/replace-object.c
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2022-07-08 16:25:19 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-07-08 16:34:30 (GMT)
commitf7b587bf656574103a0a2ad9c2337b0d15c0e92d (patch)
tree00bc34a5d6773022acd2a3a9434d50b7a9dc073a /replace-object.c
parent848fd5ae5b6506df50ae872302d94b794dc57d51 (diff)
downloadgit-f7b587bf656574103a0a2ad9c2337b0d15c0e92d.zip
git-f7b587bf656574103a0a2ad9c2337b0d15c0e92d.tar.gz
git-f7b587bf656574103a0a2ad9c2337b0d15c0e92d.tar.bz2
xdiff: introduce XDL_ALLOC_GROW()
Add a helper to grow an array. This is analogous to ALLOC_GROW() in the rest of the codebase but returns −1 on allocation failure to accommodate other users of libxdiff such as libgit2. It will also return a error if the multiplication overflows while calculating the new allocation size. Note that this keeps doubling on reallocation like the code it is replacing rather than increasing the existing size by half like ALLOC_GROW(). It does however copy ALLOC_GROW()'s trick of adding a small amount to the new allocation to avoid a lot of reallocations at small sizes. Note that xdl_alloc_grow_helper() uses long rather than size_t for `nr` and `alloc` to match the existing code. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'replace-object.c')
0 files changed, 0 insertions, 0 deletions