|
add compile line to description
According to the definition of rwt_free_store in tests/include/rw_new.h, the array member clearly has an extent of 2. Why the loop in file tests/src/new.cpp at line 629 is hard-coded for 16 iterations is bewildering. Unless someone knows why this is, I'm inclined to just change it to 2.
It looks like someone is being tricky. They are assuming that every member in rwt_free_store is contiguous [i.e. no padding], and they are actually comparing each of new_calls_, delete_calls_, blocks_, bytes_, max_blocks_, max_bytes_ and max_block_size_ with that one loop. If you decide to fix this, you'll probably end up writing eight loops of two iterations each.
Also, I'd prefer that the 2 isn't hardcoded and that you use something like sizeof (array) / sizeof (*array), or a size macro instead. Travis, If you could, give the following patch a whirl (or quick review $ svn diff
Index: tests/src/new.cpp
===================================================================
--- tests/src/new.cpp (revision 644444)
+++ tests/src/new.cpp (working copy)
@@ -604,6 +604,17 @@
return ret;
}
+static void
+rwt_checkpoint_compare (_RWSTD_SIZE_T* diffs, _RWSTD_SIZE_T n,
+ const _RWSTD_SIZE_T* st0, const _RWSTD_SIZE_T*
st1,
+ bool& diff_0)
+{
+ for (_RWSTD_SIZE_T i = 0; i != n; ++i) {
+ diffs [i] = st1 [i] - st0 [i];
+ if (diffs [i])
+ diff_0 = false;
+ }
+}
_TEST_EXPORT rwt_free_store*
rwt_checkpoint (const rwt_free_store *st0, const rwt_free_store *st1)
@@ -616,21 +627,24 @@
// of the free_store specified by the arguments
static rwt_free_store diff;
-
memset (&diff, 0, sizeof diff);
- size_t* diffs = diff.new_calls_;
- const size_t* st0_args = st0->new_calls_;
- const size_t* st1_args = st1->new_calls_;
-
bool diff_0 = true; // difference of 0 (i.e., none)
- for (size_t i = 0; i != 16; ++i) {
- diffs [i] = st1_args [i] - st0_args [i];
- if (diffs [i])
- diff_0 = false;
- }
+#define EXTENT(array) (sizeof (array) / sizeof(*array))
+#define COMPARE(member) \
+ rwt_checkpoint_compare (diff.member, EXTENT(diff.member),\
+ st0->member, st1->member, diff_0)
+ COMPARE(new_calls_);
+ COMPARE(delete_calls_);
+ COMPARE(delete_0_calls_);
+ COMPARE(blocks_);
+ COMPARE(bytes_);
+ COMPARE(max_blocks_);
+ COMPARE(max_bytes_);
+ COMPARE(max_block_size_);
+
if (diff_0)
return 0;
The 0.new test seems to be okay with it. Thanks, See this thread
Merged in 4.2.x branch thus: http://svn.apache.org/viewvc?view=rev&revision=648752
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Brad, you might want to look into this while investigating
STDCXX-709.