[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r14391: Do not allocate excess space for named_flag and unnamed_flag (in tor/trunk: . src/or)



Author: nickm
Date: 2008-04-17 16:23:13 -0400 (Thu, 17 Apr 2008)
New Revision: 14391

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/dirvote.c
Log:
 r15230@tombo:  nickm | 2008-04-17 16:18:08 -0400
 Do not allocate excess space for named_flag and unnamed_flag in dirvote.c.  Fixes bug 662.  Not a dangerous bug: sizeof(int*) is at least as big as sizeof(int) everywhere.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r15230] on 49666b30-7950-49c5-bedf-9dc8f3168102

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2008-04-17 19:03:24 UTC (rev 14390)
+++ tor/trunk/ChangeLog	2008-04-17 20:23:13 UTC (rev 14391)
@@ -22,6 +22,8 @@
       0.2.0.1-alpha.  Spotted by lodger.
     - Reduce the default smartlist size from 32 to 16; it turns out that
       most smartlists hold around 8-12 elements tops.
+    - Avoid allocating extra space when computing consensuses on
+      64-bit platforms.  Bug spotted by aakova.
 
   o Minor features:
     - Allow separate log levels to be configured for different logging

Modified: tor/trunk/src/or/dirvote.c
===================================================================
--- tor/trunk/src/or/dirvote.c	2008-04-17 19:03:24 UTC (rev 14390)
+++ tor/trunk/src/or/dirvote.c	2008-04-17 20:23:13 UTC (rev 14391)
@@ -641,8 +641,8 @@
     n_voter_flags = tor_malloc_zero(sizeof(int) * smartlist_len(votes));
     n_flag_voters = tor_malloc_zero(sizeof(int) * smartlist_len(flags));
     flag_map = tor_malloc_zero(sizeof(int*) * smartlist_len(votes));
-    named_flag = tor_malloc_zero(sizeof(int*) * smartlist_len(votes));
-    unnamed_flag = tor_malloc_zero(sizeof(int*) * smartlist_len(votes));
+    named_flag = tor_malloc_zero(sizeof(int) * smartlist_len(votes));
+    unnamed_flag = tor_malloc_zero(sizeof(int) * smartlist_len(votes));
     for (i = 0; i < smartlist_len(votes); ++i)
       unnamed_flag[i] = named_flag[i] = -1;
     chosen_named_idx = smartlist_string_pos(flags, "Named");