Resize the buffer allocation to make more space.
This will attempt to grow the buffer to accommodate the target size.
If the buffer refers to memory that was not allocated by libgit2 (i.e.
the asize
field is zero), then ptr
will be replaced with a newly
allocated block of data. Be careful so that memory allocated by the
caller is not lost. As a special variant, if you pass target_size
as
0 and the memory is not allocated by libgit2, this will allocate a new
buffer of size size
and copy the external data into it.
Currently, this will never shrink a buffer, only expand it.
If the allocation fails, this will return an error and the buffer will be marked as invalid for future operations, invaliding the contents.
The desired available size
0 on success, -1 on allocation failure