* lib/bitset/vector.c (vbitset_resize): Factor computation.
* lib/bitset.c, lib/bitset/stats.c, lib/bitsetv.c: Prefer
xzalloc to xcalloc.
Suggested by Paul Eggert.
+2019-09-06 Akim Demaille <akim@lrde.epita.fr>
+
+ bitset: style changes
+ * lib/bitset/vector.c (vbitset_resize): Factor computation.
+ * lib/bitset.c, lib/bitset/stats.c, lib/bitsetv.c: Prefer
+ xzalloc to xcalloc.
+ Suggested by Paul Eggert.
+
2019-09-06 Akim Demaille <akim@lrde.epita.fr>
bitset: check memory allocation
{
size_t bytes = bitset_bytes (type, n_bits);
- bitset bset = xcalloc (1, bytes);
+ bitset bset = xzalloc (bytes);
/* The cache is disabled until some elements are allocated. If we
have variable length arrays, then we may need to allocate a dummy
case BITSET_ARRAY:
{
size_t bytes = abitset_bytes (n_bits);
- bset->s.bset = xcalloc (1, bytes);
+ bset->s.bset = xzalloc (bytes);
abitset_init (bset->s.bset, n_bits);
}
break;
case BITSET_LIST:
{
size_t bytes = lbitset_bytes (n_bits);
- bset->s.bset = xcalloc (1, bytes);
+ bset->s.bset = xzalloc (bytes);
lbitset_init (bset->s.bset, n_bits);
}
break;
case BITSET_TABLE:
{
size_t bytes = tbitset_bytes (n_bits);
- bset->s.bset = xcalloc (1, bytes);
+ bset->s.bset = xzalloc (bytes);
tbitset_init (bset->s.bset, n_bits);
}
break;
case BITSET_VECTOR:
{
size_t bytes = vbitset_bytes (n_bits);
- bset->s.bset = xcalloc (1, bytes);
+ bset->s.bset = xzalloc (bytes);
vbitset_init (bset->s.bset, n_bits);
}
break;
memset (VBITSET_WORDS (src) + oldsize, 0,
(newsize - oldsize) * sizeof (bitset_word));
- VBITSET_SIZE (src) = newsize;
}
else
{
}
/* Need to prune any excess bits. FIXME. */
-
- VBITSET_SIZE (src) = newsize;
}
+ VBITSET_SIZE (src) = newsize;
BITSET_NBITS_ (src) = n_bits;
return n_bits;
}
/* Allocate vector table at head of bitset array. */
size_t vector_bytes = (n_vecs + 1) * sizeof (bitset) + bytes - 1;
vector_bytes -= vector_bytes % bytes;
- bitset *bsetv = xcalloc (1, vector_bytes + bytes * n_vecs);
+ bitset *bsetv = xzalloc (vector_bytes + bytes * n_vecs);
bitset_bindex i = 0;
for (i = 0; i < n_vecs; i++)