[or-cvs] r10941: Maybe fix #471. Compute the size of bitfields more correctly (tor/trunk/src/common)

weasel at seul.org weasel at seul.org
Fri Jul 27 04:45:42 UTC 2007


Author: weasel
Date: 2007-07-27 00:45:42 -0400 (Fri, 27 Jul 2007)
New Revision: 10941

Modified:
   tor/trunk/src/common/container.h
Log:
Maybe fix #471.  Compute the size of bitfields more correctly.  Nick, please check.

Modified: tor/trunk/src/common/container.h
===================================================================
--- tor/trunk/src/common/container.h	2007-07-27 01:10:23 UTC (rev 10940)
+++ tor/trunk/src/common/container.h	2007-07-27 04:45:42 UTC (rev 10941)
@@ -282,7 +282,7 @@
 static INLINE bitarray_t *
 bitarray_init_zero(int n_bits)
 {
-  size_t sz = (n_bits+BITARRAY_MASK) & BITARRAY_MASK;
+  size_t sz = (n_bits+BITARRAY_MASK) / (1u << BITARRAY_SHIFT);
   return tor_malloc_zero(sz*sizeof(unsigned int));
 }
 /** Free the bit array <b>ba</b>. */



More information about the tor-commits mailing list