]> Savannah Git Hosting - gnulib.git/commitdiff
bitset: style changes
authorAkim Demaille <akim.demaille@gmail.com>
Fri, 6 Sep 2019 09:38:48 +0000 (11:38 +0200)
committerAkim Demaille <akim.demaille@gmail.com>
Sun, 8 Sep 2019 06:38:49 +0000 (08:38 +0200)
* 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.

ChangeLog
lib/bitset.c
lib/bitset/stats.c
lib/bitset/vector.c
lib/bitsetv.c

index 077471de997061033f1888207268e0c2c57b1328..5c226ce436ab0b592b0c0169062cd7dec66d9444 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+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
index cccb1e83476a5fd326f7835c3bbecbe113f12549..6b983f438fad263ce67ca851adc66b28d58a428e 100644 (file)
@@ -129,7 +129,7 @@ bitset_alloc (bitset_bindex n_bits, enum bitset_type type)
 {
   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
index da73cdcac5227b7b6cf5a1b9d624521a8a1a0f64..fd1ca5912a48a1225671d0a0133980b8862305ce 100644 (file)
@@ -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;
index 5e543283a271cf8d4f872f1ab1b31070639ad149..ac9ba803b68be9c171421082fd8a293c0e834e97 100644 (file)
@@ -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;
 }
index b7d0a0191399649a62ffb1c31d492db4717d6abd..745f27aefcb9a76044de9aeb951448bb4630a549 100644 (file)
@@ -41,7 +41,7 @@ bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex 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++)