Tue 10 Jan 2006 09:50:42 PM UTC, comment #2:
patch to fix it :
This patch removes int in the STL-homemade implementation
int is not portable
long is portable ;)
some other ints may need to be removed in the code elsewhere, I have not checked, but this patch is sufficient to run the testsuite on the commandline.
Index: container.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/container.h,v
retrieving revision 1.1
diff -u -r1.1 container.h
--- container.h 20 Dec 2005 20:57:00 -0000 1.1
+++ container.h 10 Jan 2006 21:48:20 -0000
@@ -36,7 +36,7 @@
size_t operator()(const T& data) const
{
unsigned char* p = (unsigned char*) &data;
- int size = sizeof(T);
+ long size = sizeof(T);
return sdbm_hash(p, size);
}
@@ -203,7 +203,7 @@
// they are added or removed from the active part of the array.
public:
array() : m_buffer(0), m_size(0), m_buffer_size(0) {}
- array(int size_hint) : m_buffer(0), m_size(0), m_buffer_size(0) { resize(size_hint); }
+ array(long size_hint) : m_buffer(0), m_size(0), m_buffer_size(0) { resize(size_hint); }
array(const array<T>& a)
:
m_buffer(0),
@@ -217,9 +217,9 @@
}
// Basic array access.
- T& operator[](int index) { assert(index >= 0 && index < m_size); return m_buffer[index]; }
- const T& operator[](int index) const { assert(index >= 0 && index < m_size); return m_buffer[index]; }
- int size() const { return m_size; }
+ T& operator[](long index) { assert(index >= 0 && index < m_size); return m_buffer[index]; }
+ const T& operator[](long index) const { assert(index >= 0 && index < m_size); return m_buffer[index]; }
+ long size() const { return m_size; }
void push_back(const T& val)
// Insert the given element at the end of the array.
@@ -229,7 +229,7 @@
// resize() may munge the element storage!
assert(&val < &m_buffer[0] || &val > &m_buffer[m_buffer_size]);
- int new_size = m_size + 1;
+ long new_size = m_size + 1;
resize(new_size);
(*this)[new_size-1] = val;
}
@@ -261,13 +261,13 @@
// Array copy. Copies the contents of a into this array.
{
resize(a.size());
- for (int i = 0; i < m_size; i++) {
+ for (long i = 0; i < m_size; i++) {
*(m_buffer + i) = a[i];
}
}
- void remove(int index)
+ void remove(long index)
// Removing an element from the array is an expensive operation!
// It compacts only after removing the last element.
{
@@ -287,7 +287,7 @@
}
- void insert(int index, const T& val = T())
+ void insert(long index, const T& val = T())
// Insert the given object at the given index shifting all the elements up.
{
assert(index >= 0 && index <= m_size);
@@ -312,7 +312,7 @@
}
- void append(const T other[], int count)
+ void append(const T other[], long count)
// Append the given data to our array.
{
if (count > 0)
@@ -328,7 +328,7 @@
}
- void resize(int new_size)
+ void resize(long new_size)
// Preserve existing elements via realloc.
//
// Newly created elements are initialized with default element
@@ -336,11 +336,11 @@
{
assert(new_size >= 0);
- int old_size = m_size;
+ long old_size = m_size;
m_size = new_size;
// Destruct old elements (if we're shrinking).
- {for (int i = new_size; i < old_size; i++) {
+ {for (long i = new_size; i < old_size; i++) {
(m_buffer + i)->~T();
}}
@@ -351,24 +351,24 @@
// don't compact yet.
assert(m_buffer != 0);
} else {
- int new_buffer_size = m_size + (m_size >> 2);
+ long new_buffer_size = m_size + (m_size >> 2);
reserve(new_buffer_size);
}
// Copy default T into new elements.
- {for (int i = old_size; i < new_size; i++) {
+ {for (long i = old_size; i < new_size; i++) {
new (m_buffer + i) T(); // placement new
}}
}
- void reserve(int rsize)
+ void reserve(long rsize)
// @@ TODO change this to use ctor, dtor, and operator=
// instead of preserving existing elements via binary copy via
// realloc?
{
assert(m_size >= 0);
- int old_size = m_buffer_size;
+ long old_size = m_buffer_size;
old_size = old_size; // don't warn that this is unused.
m_buffer_size = rsize;
@@ -404,8 +404,8 @@
private:
T* m_buffer;
- int m_size;
- int m_buffer_size;
+ long m_size;
+ long m_buffer_size;
};
@@ -423,7 +423,7 @@
// table will be, default it to that size when you create it.
public:
hash() : m_table(NULL) { }
- hash(int size_hint) : m_table(NULL) { set_capacity(size_hint); }
+ hash(long size_hint) : m_table(NULL) { set_capacity(size_hint); }
~hash() { clear(); }
hash(const hash<T,U,hash_functor>& src)
@@ -452,7 +452,7 @@
void set(const T& key, const U& value)
// Set a new or existing value under the key, to the value.
{
- int index = find_index(key);
+ long index = find_index(key);
if (index >= 0)
{
E(index).second = value;
@@ -473,7 +473,7 @@
m_table->m_entry_count++;
unsigned int hash_value = hash_functor()(key);
- int index = hash_value & m_table->m_size_mask;
+ long index = hash_value & m_table->m_size_mask;
entry* natural_entry = &(E(index));
@@ -485,7 +485,7 @@
else
{
// Find a blank spot.
- int blank_index = index;
+ long blank_index = index;
for (;;)
{
blank_index = (blank_index + 1) & m_table->m_size_mask;
@@ -493,7 +493,7 @@
}
entry* blank_entry = &E(blank_index);
- if (int(natural_entry->m_hash_value & m_table->m_size_mask) == index)
+ if (long(natural_entry->m_hash_value & m_table->m_size_mask) == index)
{
// Collision. Link into this chain.
@@ -513,7 +513,7 @@
// entry must be moved.
// Find natural location of collided element (i.e. root of chain)
- int collided_index = natural_entry->m_hash_value & m_table->m_size_mask;
+ long collided_index = natural_entry->m_hash_value & m_table->m_size_mask;
for (;;)
{
entry* e = &E(collided_index);
@@ -543,7 +543,7 @@
if (m_table)
{
// Delete the entries.
- for (int i = 0, n = m_table->m_size_mask; i <= n; i++)
+ for (long i = 0, n = m_table->m_size_mask; i <= n; i++)
{
entry* e = &E(i);
if (e->is_empty() == false)
@@ -575,7 +575,7 @@
// If value == NULL, return true or false according to the
// presence of the key, but don't touch *value.
{
- int index = find_index(key);
+ long index = find_index(key);
if (index >= 0)
{
if (value) {
@@ -587,7 +587,7 @@
}
- int size()
+ long size()
{
return m_table == NULL ? 0 : m_table->m_entry_count;
}
@@ -619,12 +619,12 @@
set_capacity(n);
}
- void set_capacity(int new_size)
+ void set_capacity(long new_size)
// Size the hash so that it can comfortably contain the given
// number of elements. If the hash already contains more
// elements than new_size, then this may be a no-op.
{
- int new_raw_size = (new_size * 3) / 2;
+ long new_raw_size = (new_size * 3) / 2;
if (new_raw_size < size()) { return; }
set_raw_capacity(new_raw_size);
@@ -633,7 +633,7 @@
// Behaves much like std::pair
struct entry
{
- int m_next_in_chain; // internal chaining for collisions
+ long m_next_in_chain; // internal chaining for collisions
size_t m_hash_value; // avoids recomputing. Worthwhile?
T first;
U second;
@@ -643,7 +643,7 @@
: m_next_in_chain(e.m_next_in_chain), m_hash_value(e.m_hash_value), first(e.first), second(e.second)
{
}
- entry(const T& key, const U& value, int next_in_chain, int hash_value)
+ entry(const T& key, const U& value, long next_in_chain, long hash_value)
: m_next_in_chain(next_in_chain), m_hash_value(hash_value), first(key), second(value)
{
}
@@ -724,7 +724,7 @@
}
const hash* m_hash;
- int m_index;
+ long m_index;
};
friend struct const_iterator;
@@ -756,7 +756,7 @@
if (m_table == 0) return iterator(NULL, 0);
// Scan til we hit the first valid entry.
- int i0 = 0;
+ long i0 = 0;
while (i0 <= m_table->m_size_mask
&& E(i0).is_empty())
{
@@ -771,7 +771,7 @@
iterator find(const T& key)
{
- int index = find_index(key);
+ long index = find_index(key);
if (index >= 0)
{
return iterator(this, index);
@@ -783,17 +783,17 @@
private:
- int find_index(const T& key) const
+ long find_index(const T& key) const
// Find the index of the matching entry. If no match, then return -1.
{
if (m_table == NULL) return -1;
size_t hash_value = hash_functor()(key);
- int index = hash_value & m_table->m_size_mask;
+ long index = hash_value & m_table->m_size_mask;
const entry* e = &E(index);
if (e->is_empty()) return -1;
- if (int(e->m_hash_value & m_table->m_size_mask) != index) return -1; // occupied by a collider
+ if (long(e->m_hash_value & m_table->m_size_mask) != index) return -1; // occupied by a collider
for (;;)
{
@@ -819,13 +819,13 @@
}
// Helpers.
- entry& E(int index)
+ entry& E(long index)
{
assert(m_table);
assert(index >= 0 && index <= m_table->m_size_mask);
return (((entry) (m_table + 1)) + index);
}
- const entry& E(int index) const
+ const entry& E(long index) const
{
assert(m_table);
assert(index >= 0 && index <= m_table->m_size_mask);
@@ -833,7 +833,7 @@
}
- void set_raw_capacity(int new_size)
+ void set_raw_capacity(long new_size)
// Resize the hash table to the given size (Rehash the
// contents of the current table). The arg is the number of
// hash table entries, not the number of elements we should
@@ -846,7 +846,7 @@
}
// Force new_size to be a power of two.
- int bits = fchop(log2((float)(new_size-1)) + 1);
+ long bits = fchop(log2((float)(new_size-1)) + 1);
assert((1 << bits) >= new_size);
new_size = 1 << bits;
@@ -864,7 +864,7 @@
new_hash.m_table->m_entry_count = 0;
new_hash.m_table->m_size_mask = new_size - 1;
- {for (int i = 0; i < new_size; i++)
+ {for (long i = 0; i < new_size; i++)
{
new_hash.E(i).m_next_in_chain = -2; // mark empty
}}
@@ -872,7 +872,7 @@
// Copy stuff to new_hash
if (m_table)
{
- for (int i = 0, n = m_table->m_size_mask; i <= n; i++)
+ for (long i = 0, n = m_table->m_size_mask; i <= n; i++)
{
entry* e = &E(i);
if (e->is_empty() == false)
@@ -894,8 +894,8 @@
struct table
{
- int m_entry_count;
- int m_size_mask;
+ long m_entry_count;
+ long m_size_mask;
// entry array goes here!
};
table* m_table;
|