[Avida-SVN] r3458 - in development/source: actions platform/tcmalloc targets/avida-viewer tools
brysonda at myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Fri Oct 9 09:49:56 PDT 2009
Author: brysonda
Date: 2009-10-09 12:49:56 -0400 (Fri, 09 Oct 2009)
New Revision: 3458
Modified:
development/source/actions/PopulationActions.cc
development/source/platform/tcmalloc/tcmalloc.cc
development/source/targets/avida-viewer/cMenuWindow.cc
development/source/targets/avida-viewer/cZoomScreen.cc
development/source/targets/avida-viewer/cZoomScreen.h
development/source/tools/cDataFileManager.cc
development/source/tools/tDictionary.h
development/source/tools/tHashTable.h
development/source/tools/tObjectFactory.h
Log:
Squash all remaining compiler warnings under Xcode/GCC 4.2, including the whole slew of signed/unsigned comparison warnings in tcmalloc.
Modified: development/source/actions/PopulationActions.cc
===================================================================
--- development/source/actions/PopulationActions.cc 2009-10-09 11:36:19 UTC (rev 3457)
+++ development/source/actions/PopulationActions.cc 2009-10-09 16:49:56 UTC (rev 3458)
@@ -4036,9 +4036,6 @@
assert(m_threshold >= 0.0);
assert(geometry == nGeometry::GRID || geometry == nGeometry::TORUS);
- double level;
- int target_cell, current_cell;
- int row_adj, col_adj;
cPopulation& pop = m_world->GetPopulation();
int res_id = m_world->GetPopulation().GetResourceCount().GetResourceCountID(m_resname);
@@ -4046,8 +4043,8 @@
for (int i = 0; i < m_numradii; i++) {
- target_cell = m_world->GetRandom().GetInt(0, pop.GetSize()-1);
- level = pop.GetResourceCount().GetSpatialResource(res_id).GetAmount(target_cell);
+ int target_cell = m_world->GetRandom().GetInt(0, pop.GetSize()-1);
+ double level = pop.GetResourceCount().GetSpatialResource(res_id).GetAmount(target_cell);
if(level < m_threshold) {
const int current_row = target_cell / world_x;
@@ -4060,6 +4057,9 @@
for(int col = current_col - m_radius; col <= current_col + m_radius; col++) {
if( ((col < 0) || (col >= world_x)) && (geometry == nGeometry::GRID) ) continue;
+ int row_adj = 0;
+ int col_adj = 0;
+
if(geometry == nGeometry::TORUS) {
row_adj = (row + world_y) % world_y;
col_adj = (col + world_x) % world_x;
@@ -4068,7 +4068,7 @@
col_adj = col;
}
- current_cell = (world_x * row_adj) + col_adj;
+ int current_cell = (world_x * row_adj) + col_adj;
cPopulationCell& cell = pop.GetCell(current_cell);
if (cell.IsOccupied()) {
pop.KillOrganism(cell);
Modified: development/source/platform/tcmalloc/tcmalloc.cc
===================================================================
--- development/source/platform/tcmalloc/tcmalloc.cc 2009-10-09 11:36:19 UTC (rev 3457)
+++ development/source/platform/tcmalloc/tcmalloc.cc 2009-10-09 16:49:56 UTC (rev 3458)
@@ -135,7 +135,7 @@
// should keep this value big because various incarnations of Linux
// have small limits on the number of mmap() regions per
// address-space.
-static const int kMinSystemAlloc = 1 << (20 - kPageShift);
+static const unsigned int kMinSystemAlloc = 1 << (20 - kPageShift);
// Number of objects to move between a per-thread list and a central
// list in one shot. We want this to be not too small so we can
@@ -338,12 +338,12 @@
// Initialize the mapping arrays
static void InitSizeClasses() {
// Special initialization for small sizes
- for (int lg = 0; lg < kAlignShift; lg++) {
+ for (unsigned int lg = 0; lg < kAlignShift; lg++) {
size_base[lg] = 1;
size_shift[lg] = kAlignShift;
}
- int next_class = 1;
+ unsigned int next_class = 1;
int alignshift = kAlignShift;
int last_lg = -1;
for (size_t size = kAlignment; size <= kMaxSize; size += (1 << alignshift)) {
@@ -388,7 +388,7 @@
// Double-check sizes just to be safe
for (size_t size = 0; size <= kMaxSize; size++) {
- const int sc = SizeClass(size);
+ const unsigned int sc = SizeClass(size);
if (sc == 0) {
MESSAGE("Bad size class %d for %" PRIuS "\n", sc, size);
abort();
@@ -769,7 +769,7 @@
free_pages_(0),
system_bytes_(0) {
DLL_Init(&large_);
- for (int i = 0; i < kMaxPages; i++) {
+ for (unsigned int i = 0; i < kMaxPages; i++) {
DLL_Init(&free_[i]);
}
}
@@ -842,7 +842,7 @@
span->free = 0;
Event(span, 'A', n);
- const int extra = span->length - n;
+ const unsigned int extra = span->length - n;
ASSERT(extra >= 0);
if (extra > 0) {
Span* leftover = NewSpan(span->start + n, extra);
@@ -1211,7 +1211,7 @@
// just iterates over the sizeclasses but does so without taking a lock.
// Returns true on success.
// May temporarily lock a "random" size class.
- static bool EvictRandomSizeClass(int locked_size_class, bool force);
+ static bool EvictRandomSizeClass(unsigned int locked_size_class, bool force);
// REQUIRES: lock_ is *not* held.
// Tries to shrink the Cache. If force is true it will relase objects to
@@ -1363,9 +1363,9 @@
}
bool TCMalloc_Central_FreeList::EvictRandomSizeClass(
- int locked_size_class, bool force) {
- static int race_counter = 0;
- int t = race_counter++; // Updated without a lock, but who cares.
+ unsigned int locked_size_class, bool force) {
+ static unsigned int race_counter = 0;
+ unsigned int t = race_counter++; // Updated without a lock, but who cares.
if (t >= kNumClasses) {
while (t >= kNumClasses) {
t -= kNumClasses;
@@ -1586,7 +1586,7 @@
void TCMalloc_ThreadCache::Cleanup() {
// Put unused memory back into central cache
- for (int cl = 0; cl < kNumClasses; ++cl) {
+ for (unsigned int cl = 0; cl < kNumClasses; ++cl) {
if (list_[cl].length() > 0) {
ReleaseToCentralCache(cl, list_[cl].length());
}
@@ -1656,7 +1656,7 @@
// pretty soon and the low-water marks will be high on that call.
//int64 start = CycleClock::Now();
- for (int cl = 0; cl < kNumClasses; cl++) {
+ for (unsigned int cl = 0; cl < kNumClasses; cl++) {
FreeList* list = &list_[cl];
const int lowmark = list->lowwatermark();
if (lowmark > 0) {
@@ -1722,7 +1722,7 @@
span_allocator.New(); // Reduce cache conflicts
stacktrace_allocator.Init();
DLL_Init(&sampled_objects);
- for (int i = 0; i < kNumClasses; ++i) {
+ for (unsigned int i = 0; i < kNumClasses; ++i) {
central_cache[i].Init(i);
}
new ((void*)pageheap_memory) TCMalloc_PageHeap;
@@ -1825,7 +1825,7 @@
}
void TCMalloc_ThreadCache::Print() const {
- for (int cl = 0; cl < kNumClasses; ++cl) {
+ for (unsigned int cl = 0; cl < kNumClasses; ++cl) {
MESSAGE(" %5" PRIuS " : %4d len; %4d lo\n",
ByteSizeForClass(cl),
list_[cl].length(),
@@ -2144,7 +2144,7 @@
// are aligned at powers of two. We will waste time and space if
// we miss in the size class array, but that is deemed acceptable
// since memalign() should be used rarely.
- int cl = SizeClass(size);
+ unsigned int cl = SizeClass(size);
while (cl < kNumClasses && ((class_to_size[cl] & (align - 1)) != 0)) {
cl++;
}
@@ -2184,7 +2184,7 @@
}
// Skip trailing portion that we do not need to return
- const int needed = pages(size);
+ const unsigned int needed = pages(size);
ASSERT(span->length >= needed);
if (span->length > needed) {
Span* trailer = pageheap->Split(span, needed);
Modified: development/source/targets/avida-viewer/cMenuWindow.cc
===================================================================
--- development/source/targets/avida-viewer/cMenuWindow.cc 2009-10-09 11:36:19 UTC (rev 3457)
+++ development/source/targets/avida-viewer/cMenuWindow.cc 2009-10-09 16:49:56 UTC (rev 3458)
@@ -42,12 +42,10 @@
max_entry = option_array[i].GetSize();
}
- const int max_height = parent_window->Height() - 4;
const int max_width = parent_window->Width() - 4;
const int min_width = title.GetSize() + 2;
// The minimum number of columns available is determined by the title.
- const int max_rows = max_height - (title.IsEmpty() ? 0 : 2);
const int min_cols = min_width / (max_entry + 2);
const int max_cols = max_width / (max_entry + 2);
@@ -66,8 +64,6 @@
// Next, figure out how many rows we need for this to work.
num_rows = 1 + (num_options-1) / num_cols;
- // @CAO We need to identify if we have a problem fitting everything!)
-// if (num_rows > max_rows) ;
// Determine dimenstions for window
int win_height = num_rows + 4;
Modified: development/source/targets/avida-viewer/cZoomScreen.cc
===================================================================
--- development/source/targets/avida-viewer/cZoomScreen.cc 2009-10-09 11:36:19 UTC (rev 3457)
+++ development/source/targets/avida-viewer/cZoomScreen.cc 2009-10-09 16:49:56 UTC (rev 3458)
@@ -1377,7 +1377,7 @@
}
-char* cZoomScreen::GetSectionName(int in_section)
+const char* cZoomScreen::GetSectionName(int in_section)
{
switch (in_section) {
case ZOOM_SECTION_MEMORY:
@@ -1432,7 +1432,7 @@
void cZoomScreen::DoInput(int in_char)
{
- cHardwareBase * hardware = NULL;
+ cHardwareBase* hardware = NULL;
if (info.GetActiveCell()->IsOccupied()) {
hardware = &(info.GetActiveCell()->GetOrganism()->GetHardware());
}
Modified: development/source/targets/avida-viewer/cZoomScreen.h
===================================================================
--- development/source/targets/avida-viewer/cZoomScreen.h 2009-10-09 11:36:19 UTC (rev 3457)
+++ development/source/targets/avida-viewer/cZoomScreen.h 2009-10-09 16:49:56 UTC (rev 3458)
@@ -105,7 +105,7 @@
cCoords GetSectionCoords(int in_section);
//cString GetSectionName(int in_section);
- char* GetSectionName(int in_section);
+ const char* GetSectionName(int in_section);
void SetActiveSection(int in_section);
void DrawMiniMap();
Modified: development/source/tools/cDataFileManager.cc
===================================================================
--- development/source/tools/cDataFileManager.cc 2009-10-09 11:36:19 UTC (rev 3457)
+++ development/source/tools/cDataFileManager.cc 2009-10-09 16:49:56 UTC (rev 3458)
@@ -124,7 +124,8 @@
bool cDataFileManager::Remove(const cString& name)
{
- cDataFile* found_file = m_datafiles.Remove(name);
+ cDataFile* found_file = NULL;
+ m_datafiles.Remove(name, found_file);
if (found_file == NULL) return false;
delete found_file;
Modified: development/source/tools/tDictionary.h
===================================================================
--- development/source/tools/tDictionary.h 2009-10-09 11:36:19 UTC (rev 3457)
+++ development/source/tools/tDictionary.h 2009-10-09 16:49:56 UTC (rev 3458)
@@ -71,7 +71,8 @@
inline void SetValue(const cString& name, T data) { m_hash.SetValue(name, data); }
inline bool HasEntry(const cString& name) const { return m_hash.HasEntry(name); }
inline bool Find(const cString& name, T& out_data) const { return m_hash.Find(name, out_data); }
- inline T Remove(const cString& name) { return m_hash.Remove(name); }
+ inline void Remove(const cString& name) { m_hash.Remove(name); }
+ inline bool Remove(const cString& name, T& data) { return m_hash.Remove(name, data); }
inline void SetHash(int _hash) { m_hash.SetTableSize(_hash); }
inline void AsLists(tList<cString>& name_list, tList<T>& value_list) const {
m_hash.AsLists(name_list, value_list);
@@ -151,7 +152,8 @@
inline bool Find(const cString& name, T& out_data) const {
cString uname(name); uname.ToUpper(); return m_hash.Find(uname, out_data);
}
- inline T Remove(const cString& name) { cString uname(name); uname.ToUpper(); return m_hash.Remove(uname); }
+ inline void Remove(const cString& name) { cString uname(name); uname.ToUpper(); m_hash.Remove(uname); }
+ inline bool Remove(const cString& name, T& data) { cString uname(name); uname.ToUpper(); return m_hash.Remove(uname, data); }
// Fast Accessor Methods - Calling method assumes responsibility for UCasing the key
Modified: development/source/tools/tHashTable.h
===================================================================
--- development/source/tools/tHashTable.h 2009-10-09 11:36:19 UTC (rev 3457)
+++ development/source/tools/tHashTable.h 2009-10-09 16:49:56 UTC (rev 3458)
@@ -291,17 +291,18 @@
return false;
}
- DATA_TYPE Remove(const HASH_TYPE& key) {
+ bool Remove(const HASH_TYPE& key, DATA_TYPE& out_data) {
// Determine the bin that we are going to be using.
const int bin = nHashTable::HashKey<HASH_TYPE>(key, table_size);
- DATA_TYPE out_data;
+ bool found = false;
assert(cell_array[bin] != NULL);
list_it.Set(cell_array[bin]);
// If we are deleting the first entry in this bin we must clean up...
if (list_it.Get()->key == key) {
out_data = list_it.Get()->data;
+ found = true;
delete list_it.Remove();
list_it.Next();
entry_count--;
@@ -318,6 +319,7 @@
while (list_it.Next() != NULL && list_it.Get()->id == bin) {
if (list_it.Get()->key == key) {
out_data = list_it.Get()->data;
+ found = true;
delete list_it.Remove();
entry_count--;
break;
@@ -325,9 +327,42 @@
}
}
- return out_data;
+ return found;
}
+ void Remove(const HASH_TYPE& key) {
+ // Determine the bin that we are going to be using.
+ const int bin = nHashTable::HashKey<HASH_TYPE>(key, table_size);
+
+ assert(cell_array[bin] != NULL);
+ list_it.Set(cell_array[bin]);
+
+ // If we are deleting the first entry in this bin we must clean up...
+ if (list_it.Get()->key == key) {
+ delete list_it.Remove();
+ list_it.Next();
+ entry_count--;
+ // See if the next entry is still part of this cell.
+ if (list_it.AtRoot() == false && list_it.Get()->id == bin) {
+ cell_array[bin] = list_it.GetPos();
+ } else {
+ cell_array[bin] = NULL;
+ }
+ }
+
+ // If it was not the first entry in this cell, keep looking!
+ else {
+ while (list_it.Next() != NULL && list_it.Get()->id == bin) {
+ if (list_it.Get()->key == key) {
+ delete list_it.Remove();
+ entry_count--;
+ break;
+ }
+ }
+ }
+ }
+
+
void SetTableSize(int _hash) {
// Create the new table...
table_size = _hash;
Modified: development/source/tools/tObjectFactory.h
===================================================================
--- development/source/tools/tObjectFactory.h 2009-10-09 11:36:19 UTC (rev 3457)
+++ development/source/tools/tObjectFactory.h 2009-10-09 16:49:56 UTC (rev 3458)
@@ -389,7 +389,8 @@
bool Unregister(const cString& key)
{
cMutexAutoLock lock(m_mutex);
- CreateObjectFunction func = m_create_funcs.Remove(key);
+ CreateObjectFunction func = NULL;
+ m_create_funcs.Remove(key, func);
return (func != NULL);
}
More information about the Avida-cvs
mailing list