[Avida-cvs] [avida-svn] r482 - trunk/source/cpu
brysonda@myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Sun Feb 26 08:35:01 PST 2006
Author: brysonda
Date: 2006-02-26 11:35:01 -0500 (Sun, 26 Feb 2006)
New Revision: 482
Modified:
trunk/source/cpu/cCPUMemory.cc
Log:
Fix repeatability bug. cCPUMemory::Resize() was making unsafe assumptions about the initialization of new memory flags.
Modified: trunk/source/cpu/cCPUMemory.cc
===================================================================
--- trunk/source/cpu/cCPUMemory.cc 2006-02-24 03:00:54 UTC (rev 481)
+++ trunk/source/cpu/cCPUMemory.cc 2006-02-26 16:35:01 UTC (rev 482)
@@ -21,6 +21,7 @@
cCPUMemory::cCPUMemory(int _size) : cGenome(_size), flag_array(_size)
{
+ ClearFlags();
}
cCPUMemory::cCPUMemory(const cCPUMemory & in_memory)
@@ -143,11 +144,10 @@
// Do a sloppy resize first, saving old values...
const int old_size = active_size;
- const int old_array_size = genome.GetSize();
SloppyResize(new_size);
// Clean up all of the old memory that might need it...
- for (int i = old_size; i < new_size && i < old_array_size; i++) {
+ for (int i = old_size; i < new_size; i++) {
genome[i].SetOp(0);
flag_array[i] = 0;
}
@@ -158,8 +158,14 @@
{
assert(new_size >= 0);
+ const int old_size = active_size;
+
// Do a sloppy resize, which will still have old values.
SloppyResize(new_size);
+
+ for (int i = old_size; i < new_size; i++) {
+ flag_array[i] = 0;
+ }
}
@@ -214,5 +220,6 @@
// Now just copy everything over!
for (int i = 0; i < in_genome.GetSize(); i++) {
genome[i + pos] = in_genome[i];
+ flag_array[i + pos] = 0;
}
}
More information about the Avida-cvs
mailing list