]> Savannah Git Hosting - gnulib.git/commitdiff
bitsetv: allow free on NULL.
authorAkim Demaille <akim.demaille@gmail.com>
Sun, 27 Jan 2019 17:49:36 +0000 (18:49 +0100)
committerAkim Demaille <akim.demaille@gmail.com>
Sun, 27 Jan 2019 17:49:36 +0000 (18:49 +0100)
* lib/bitsetv.c (bitsetv_free): Do nothing when the bitsetv is NULL.

ChangeLog
lib/bitsetv.c
lib/bitsetv.h

index 4e90bfd6602608c9ea568d966f7cb3cfa1aa28b7..6134044422494530e6aa1dca96cb626da9d883e2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-01-27  Akim Demaille  <akim@lrde.epita.fr>
+
+       bitsetv: allow free on NULL.
+       * lib/bitsetv.c (bitsetv_free): Do nothing when the bitsetv is NULL.
+
 2019-01-27  Bruno Haible  <bruno@clisp.org>
 
        test-framework-sh: Improve maintainability.
index e3cc5845a766f8a8434313740f212c9f788d266e..b7d0a0191399649a62ffb1c31d492db4717d6abd 100644 (file)
@@ -71,9 +71,12 @@ bitsetv_create (bitset_bindex n_vecs, bitset_bindex n_bits, unsigned attr)
 void
 bitsetv_free (bitsetv bsetv)
 {
-  for (bitset_bindex i = 0; bsetv[i]; i++)
-    BITSET_FREE_ (bsetv[i]);
-  free (bsetv);
+  if (bsetv)
+    {
+      for (bitset_bindex i = 0; bsetv[i]; i++)
+        BITSET_FREE_ (bsetv[i]);
+      free (bsetv);
+    }
 }
 
 
index 798b70d9b42d5184286725e03276ab3491a105c0..0971d7adc9027badf9d38781f83f9d1c2aa40931 100644 (file)
@@ -33,7 +33,7 @@ bitsetv bitsetv_alloc (bitset_bindex, bitset_bindex, enum bitset_type);
    attribute hints specified by ATTR.  */
 bitsetv bitsetv_create (bitset_bindex, bitset_bindex, unsigned);
 
-/* Free vector of bitsets.  */
+/* Free vector of bitsets.  Do nothing if NULL.  */
 void bitsetv_free (bitsetv);
 
 /* Zero vector of bitsets.  */