On 9/5/19 12:59 PM, Akim Demaille wrote:

            EBITSET_ELTS (src)
-            = realloc (EBITSET_ELTS (src), newsize * sizeof (tbitset_elt *));
+            = xrealloc (EBITSET_ELTS (src), newsize * sizeof (tbitset_elt *));

This code is trying to shrink the bitset, and in the unlikely event that such an attempt fails there's no need call xrealloc which will exit the whole program; the code can continue to call realloc and if that fails, the code can forge ahead with the unshrunk bitset.

There's a similar issue in the vector.c patch.

Other than that, looks OK to me; as I understand it the bitset code is not intended for libraries (as lib/bitset/stats.c already calls xcalloc, and OBSTACK_CHUNK_ALLOC and OBSTACK_CHUNK_FREE default to xmalloc and free) so it's OK for it to call xrealloc.

Come to think of it, though, what's the intent of OBSTACK_CHUNK_ALLOC and OBSTACK_CHUNK_FREE? If the intent is for the builder to replace xmalloc and free, shouldn't the including code also be able to redefine xrealloc and xrealloc?

Also, a nit in nearby code: xcalloc (1, N) is better written as xzalloc (N).

Reply via email to