summaryrefslogtreecommitdiff
path: root/lib/bitset
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2019-09-06 11:38:48 +0200
committerAkim Demaille <akim.demaille@gmail.com>2019-09-08 08:38:49 +0200
commit03add7eb9d06ab509034ba01c904a4cb36f5706b (patch)
tree553447c02501bfcb7c117d9729190ff23e21b1e7 /lib/bitset
parentd3bb911fd0f53b2c69c96da43cc0f6557f3d2dd8 (diff)
downloadgnulib-03add7eb9d06ab509034ba01c904a4cb36f5706b.tar.gz
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.
Diffstat (limited to 'lib/bitset')
-rw-r--r--lib/bitset/stats.c8
-rw-r--r--lib/bitset/vector.c4
2 files changed, 5 insertions, 7 deletions
diff --git a/lib/bitset/stats.c b/lib/bitset/stats.c
index da73cdcac5..fd1ca5912a 100644
--- a/lib/bitset/stats.c
+++ b/lib/bitset/stats.c
@@ -694,7 +694,7 @@ bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
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;
@@ -702,7 +702,7 @@ bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
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;
@@ -710,7 +710,7 @@ bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
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;
@@ -718,7 +718,7 @@ bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
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;
diff --git a/lib/bitset/vector.c b/lib/bitset/vector.c
index 5e543283a2..ac9ba803b6 100644
--- a/lib/bitset/vector.c
+++ b/lib/bitset/vector.c
@@ -82,7 +82,6 @@ vbitset_resize (bitset src, bitset_bindex n_bits)
memset (VBITSET_WORDS (src) + oldsize, 0,
(newsize - oldsize) * sizeof (bitset_word));
- VBITSET_SIZE (src) = newsize;
}
else
{
@@ -100,10 +99,9 @@ vbitset_resize (bitset src, bitset_bindex n_bits)
}
/* Need to prune any excess bits. FIXME. */
-
- VBITSET_SIZE (src) = newsize;
}
+ VBITSET_SIZE (src) = newsize;
BITSET_NBITS_ (src) = n_bits;
return n_bits;
}