git/xdiff
Phillip Wood f7b587bf65 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>
2022-07-08 09:34:30 -07:00
..
xdiff.h xdiff: introduce xdl_calloc 2022-07-08 09:34:30 -07:00
xdiffi.c xdiff: introduce XDL_ALLOC_ARRAY() 2022-07-08 09:34:30 -07:00
xdiffi.h Replace Free Software Foundation address in license notices 2017-11-09 13:21:21 +09:00
xemit.c tree-wide: apply equals-null.cocci 2022-05-02 09:50:37 -07:00
xemit.h Replace Free Software Foundation address in license notices 2017-11-09 13:21:21 +09:00
xhistogram.c xdiff: introduce XDL_CALLOC_ARRAY() 2022-07-08 09:34:30 -07:00
xinclude.h xdiff: use git-compat-util 2019-04-12 13:34:17 +09:00
xmacros.h xdiff: introduce XDL_ALLOC_GROW() 2022-07-08 09:34:30 -07:00
xmerge.c xdiff: handle allocation failure when merging 2022-02-16 10:58:16 -08:00
xpatience.c xdiff: introduce XDL_CALLOC_ARRAY() 2022-07-08 09:34:30 -07:00
xprepare.c xdiff: introduce XDL_ALLOC_GROW() 2022-07-08 09:34:30 -07:00
xprepare.h Replace Free Software Foundation address in license notices 2017-11-09 13:21:21 +09:00
xtypes.h Replace Free Software Foundation address in license notices 2017-11-09 13:21:21 +09:00
xutils.c xdiff: introduce XDL_ALLOC_GROW() 2022-07-08 09:34:30 -07:00
xutils.h xdiff: introduce XDL_ALLOC_GROW() 2022-07-08 09:34:30 -07:00