[PATCH] mini-gmp: pass correct old_size to custom reallocate function

minux minux.ma at gmail.com
Sat Feb 22 11:23:26 UTC 2020


mini-gmp currently always passes old_size == 0 to the custom
reallocate function, causing custom allocators for GMP that use
old_size to determine the amount of data to copy data to newly
allocated space to malfunction with mini-gmp.

According to GMP documentation chapter 13 for reallocate_function:
"The block may be moved if necessary or if desired, and in that case
the smaller of old_size and new_size bytes must be copied to the new
location." As in general mini-gmp cannot assume that the reallocate
function will not move the block, it should always pass non-zero
old_size to the reallocate function if it wants the old data to be

I have modified mini-gmp and its testsuite to conform to this
definition from GMP.
Patch against the latest hg tip (c44538397385) is attached.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: mini-gmp.patch
Type: application/octet-stream
Size: 2346 bytes
Desc: not available
URL: <https://gmplib.org/list-archives/gmp-devel/attachments/20200222/20cf3f9a/attachment.obj>

More information about the gmp-devel mailing list