On Thu, Mar 12, 2020 at 3:19 PM Niels Möller <ni...@lysator.liu.se> wrote: > minux <minux...@gmail.com> writes: > > Indeed, this is much simpler and avoids the risk of calling > > strlen(NULL). Thanks. > > > > Patch updated. Please take another look. > > Looks good to me. I was about to submit, but then I have one minor > question about naming. > > > #define gmp_xalloc(size) ((*gmp_allocate_func)((size))) > > -#define gmp_free(p) ((*gmp_free_func) ((p), 0)) > > +#define gmp_xfree(p, size) ((*gmp_free_func) ((p), (size))) > > +#define gmp_xrealloc(ptr, old_size, size) ((*gmp_reallocate_func)(ptr, > > old_size, size)) > > Here, "xalloc" is the traditional name (at least in GNU code, another > name is xmalloc) for an allocation function that will crash with an > error message on failure, rather than returning NULL. The name > gmp_xalloc in mini-gmp most likely dates from before support for > get_set_memory_functions was added, and then it did the same thing as > the current gmp_default_alloc, with no indirection. > > The xrealloc function is analogous (but maybe not as widely used as > xalloc). On the other hand, I don't know of any traditional function > named xfree. So maybe the least confusing naming is to strike "x" from > all the names (six in all, including the _limbs variants)?
patch updated. I actually had this question while making changes. But I took advantage of the naming convention to use gmp_xfree for the two-parameter version so that I do not have to fix all use of one-parameter gmp_free in one pass. And then for consistency, I also renamed realloc to xrealloc. Thanks.
mini-gmp.patch
Description: Binary data
_______________________________________________ gmp-devel mailing list gmp-devel@gmplib.org https://gmplib.org/mailman/listinfo/gmp-devel