[Scummvm-cvs-logs] scummvm master -> 442bcb7d3eb64f3fbde3ee5bd2b16e7c01bae469

lordhoto lordhoto at gmail.com
Wed Feb 22 20:22:28 CET 2012


This automated email contains information about 7 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
d6ac369303 COMMON: Add a size_type to Array and take advantage of it.
417cd7625c COMMON: Slight formatting fixes in array.h.
7d8da24082 COMMON: Add a size_type to Stack and FixedStack.
03959c18dc COMMON: Slight formatting fixes in stack.h.
5eabc4a2f3 COMMON: Add a size_type to List.
dac6ac66ad COMMON: Add a size_type to HashMap.
442bcb7d3e ALL: Fix some signed/unsigned comparison warnings.


Commit: d6ac36930337c178f92ddccbd6946d7a98a9c7a5
    https://github.com/scummvm/scummvm/commit/d6ac36930337c178f92ddccbd6946d7a98a9c7a5
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-22T10:59:26-08:00

Commit Message:
COMMON: Add a size_type to Array and take advantage of it.

size_type is an unsigned integer type and is used for all indices etc.

Changed paths:
    common/array.h



diff --git a/common/array.h b/common/array.h
index ef0ee27..0b952eb 100644
--- a/common/array.h
+++ b/common/array.h
@@ -42,17 +42,19 @@ namespace Common {
  */
 template<class T>
 class Array {
-protected:
-	uint _capacity;
-	uint _size;
-	T *_storage;
-
 public:
 	typedef T *iterator;
 	typedef const T *const_iterator;
 
 	typedef T value_type;
 
+	typedef uint size_type;
+
+protected:
+	size_type _capacity;
+	size_type _size;
+	T *_storage;
+
 public:
 	Array() : _capacity(0), _size(0), _storage(0) {}
 
@@ -67,7 +69,7 @@ public:
 	 * Construct an array by copying data from a regular array.
 	 */
 	template<class T2>
-	Array(const T2 *data, int n) {
+	Array(const T2 *data, size_type n) {
 		_size = n;
 		allocCapacity(n);
 		uninitialized_copy(data, data + _size, _storage);
@@ -128,19 +130,19 @@ public:
 	}
 
 
-	void insert_at(int idx, const T &element) {
-		assert(idx >= 0 && (uint)idx <= _size);
+	void insert_at(size_type idx, const T &element) {
+		assert(idx <= _size);
 		insert_aux(_storage + idx, &element, &element + 1);
 	}
 
-	void insert_at(int idx, const Array<T> &array) {
-		assert(idx >= 0 && (uint)idx <= _size);
+	void insert_at(size_type idx, const Array<T> &array) {
+		assert(idx <= _size);
 		insert_aux(_storage + idx, array.begin(), array.end());
 	}
 
 
-	T remove_at(int idx) {
-		assert(idx >= 0 && (uint)idx < _size);
+	T remove_at(size_type idx) {
+		assert(idx < _size);
 		T tmp = _storage[idx];
 		copy(_storage + idx + 1, _storage + _size, _storage + idx);
 		_size--;
@@ -151,13 +153,13 @@ public:
 
 	// TODO: insert, remove, ...
 
-	T& operator[](int idx) {
-		assert(idx >= 0 && (uint)idx < _size);
+	T& operator[](size_type idx) {
+		assert(idx < _size);
 		return _storage[idx];
 	}
 
-	const T& operator[](int idx) const {
-		assert(idx >= 0 && (uint)idx < _size);
+	const T& operator[](size_type idx) const {
+		assert(idx < _size);
 		return _storage[idx];
 	}
 
@@ -173,7 +175,7 @@ public:
 		return *this;
 	}
 
-	uint size() const {
+	size_type size() const {
 		return _size;
 	}
 
@@ -193,7 +195,7 @@ public:
 			return true;
 		if (_size != other._size)
 			return false;
-		for (uint i = 0; i < _size; ++i) {
+		for (size_type i = 0; i < _size; ++i) {
 			if (_storage[i] != other._storage[i])
 				return false;
 		}
@@ -220,7 +222,7 @@ public:
 		return _storage + _size;
 	}
 
-	void reserve(uint newCapacity) {
+	void reserve(size_type newCapacity) {
 		if (newCapacity <= _capacity)
 			return;
 
@@ -234,9 +236,9 @@ public:
 		}
 	}
 
-	void resize(uint newSize) {
+	void resize(size_type newSize) {
 		reserve(newSize);
-		for (uint i = _size; i < newSize; ++i)
+		for (size_type i = _size; i < newSize; ++i)
 			new ((void *)&_storage[i]) T();
 		_size = newSize;
 	}
@@ -249,28 +251,28 @@ public:
 	}
 
 protected:
-	static uint roundUpCapacity(uint capacity) {
+	static size_type roundUpCapacity(size_type capacity) {
 		// Round up capacity to the next power of 2;
 		// we use a minimal capacity of 8.
-		uint capa = 8;
+		size_type capa = 8;
 		while (capa < capacity)
 			capa <<= 1;
 		return capa;
 	}
 
-	void allocCapacity(uint capacity) {
+	void allocCapacity(size_type capacity) {
 		_capacity = capacity;
 		if (capacity) {
 			_storage = (T *)malloc(sizeof(T) * capacity);
 			if (!_storage)
-				::error("Common::Array: failure to allocate %u bytes", capacity * (uint)sizeof(T));
+				::error("Common::Array: failure to allocate %u bytes", capacity * (size_type)sizeof(T));
 		} else {
 			_storage = 0;
 		}
 	}
 
-	void freeStorage(T *storage, const uint elements) {
-		for (uint i = 0; i < elements; ++i)
+	void freeStorage(T *storage, const size_type elements) {
+		for (size_type i = 0; i < elements; ++i)
 			storage[i].~T();
 		free(storage);
 	}
@@ -291,9 +293,9 @@ protected:
 	iterator insert_aux(iterator pos, const_iterator first, const_iterator last) {
 		assert(_storage <= pos && pos <= _storage + _size);
 		assert(first <= last);
-		const uint n = last - first;
+		const size_type n = last - first;
 		if (n) {
-			const uint idx = pos - _storage;
+			const size_type idx = pos - _storage;
 			if (_size + n > _capacity || (_storage <= first && first <= _storage + _size)) {
 				T *const oldStorage = _storage;
 


Commit: 417cd7625c44bcae1b40c0a0b86ea6592ffd813c
    https://github.com/scummvm/scummvm/commit/417cd7625c44bcae1b40c0a0b86ea6592ffd813c
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-22T11:00:11-08:00

Commit Message:
COMMON: Slight formatting fixes in array.h.

Changed paths:
    common/array.h



diff --git a/common/array.h b/common/array.h
index 0b952eb..a2c3023 100644
--- a/common/array.h
+++ b/common/array.h
@@ -24,7 +24,7 @@
 
 #include "common/scummsys.h"
 #include "common/algorithm.h"
-#include "common/textconsole.h"	// For error()
+#include "common/textconsole.h" // For error()
 #include "common/memory.h"
 
 namespace Common {
@@ -153,17 +153,17 @@ public:
 
 	// TODO: insert, remove, ...
 
-	T& operator[](size_type idx) {
+	T &operator[](size_type idx) {
 		assert(idx < _size);
 		return _storage[idx];
 	}
 
-	const T& operator[](size_type idx) const {
+	const T &operator[](size_type idx) const {
 		assert(idx < _size);
 		return _storage[idx];
 	}
 
-	Array<T>& operator=(const Array<T> &array) {
+	Array<T> &operator=(const Array<T> &array) {
 		if (this == &array)
 			return *this;
 
@@ -201,24 +201,24 @@ public:
 		}
 		return true;
 	}
+
 	bool operator!=(const Array<T> &other) const {
 		return !(*this == other);
 	}
 
-
-	iterator		begin() {
+	iterator       begin() {
 		return _storage;
 	}
 
-	iterator		end() {
+	iterator       end() {
 		return _storage + _size;
 	}
 
-	const_iterator	begin() const {
+	const_iterator begin() const {
 		return _storage;
 	}
 
-	const_iterator	end() const {
+	const_iterator end() const {
 		return _storage + _size;
 	}
 


Commit: 7d8da240820fa9cafc8e3090c007051a29d8d79f
    https://github.com/scummvm/scummvm/commit/7d8da240820fa9cafc8e3090c007051a29d8d79f
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-22T11:07:40-08:00

Commit Message:
COMMON: Add a size_type to Stack and FixedStack.

Changed paths:
    common/stack.h



diff --git a/common/stack.h b/common/stack.h
index 0d13049..235715d 100644
--- a/common/stack.h
+++ b/common/stack.h
@@ -30,12 +30,11 @@ namespace Common {
 /**
  * Extremly simple fixed size stack class.
  */
-template<class T, int MAX_SIZE = 10>
+template<class T, uint MAX_SIZE = 10>
 class FixedStack {
-protected:
-	T	_stack[MAX_SIZE];
-	int	_size;
 public:
+	typedef uint size_type;
+
 	FixedStack<T, MAX_SIZE>() : _size(0) {}
 
 	bool empty() const {
@@ -61,17 +60,20 @@ public:
 		--_size;
 		return tmp;
 	}
-	int size() const {
+	size_type size() const {
 		return _size;
 	}
-	T &operator[](int i) {
-		assert(0 <= i && i < MAX_SIZE);
+	T &operator[](size_type i) {
+		assert(i < MAX_SIZE);
 		return _stack[i];
 	}
-	const T &operator[](int i) const {
-		assert(0 <= i && i < MAX_SIZE);
+	const T &operator[](size_type i) const {
+		assert(i < MAX_SIZE);
 		return _stack[i];
 	}
+protected:
+	T	_stack[MAX_SIZE];
+	size_type	_size;
 };
 
 
@@ -84,6 +86,8 @@ private:
 	Array<T>	_stack;
 
 public:
+	typedef typename Array<T>::size_type size_type;
+
 	Stack<T>() {}
 	Stack<T>(const Array<T> &stackContent) : _stack(stackContent) {}
 
@@ -107,13 +111,13 @@ public:
 		_stack.pop_back();
 		return tmp;
 	}
-	int size() const {
+	size_type size() const {
 		return _stack.size();
 	}
-	T &operator[](int i) {
+	T &operator[](size_type i) {
 		return _stack[i];
 	}
-	const T &operator[](int i) const {
+	const T &operator[](size_type i) const {
 		return _stack[i];
 	}
 };


Commit: 03959c18dc162f4970ee40931a00ac242affda1b
    https://github.com/scummvm/scummvm/commit/03959c18dc162f4970ee40931a00ac242affda1b
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-22T11:08:40-08:00

Commit Message:
COMMON: Slight formatting fixes in stack.h.

Changed paths:
    common/stack.h



diff --git a/common/stack.h b/common/stack.h
index 235715d..bc5de9a 100644
--- a/common/stack.h
+++ b/common/stack.h
@@ -40,40 +40,49 @@ public:
 	bool empty() const {
 		return _size <= 0;
 	}
+
 	void clear() {
 		_size = 0;
 	}
+
 	void push(const T &x) {
 		assert(_size < MAX_SIZE);
 		_stack[_size++] = x;
 	}
+
 	const T &top() const {
 		assert(_size > 0);
 		return _stack[_size - 1];
 	}
+
 	T &top() {
 		assert(_size > 0);
 		return _stack[_size - 1];
 	}
+
 	T pop() {
 		T tmp = top();
 		--_size;
 		return tmp;
 	}
+
 	size_type size() const {
 		return _size;
 	}
+
 	T &operator[](size_type i) {
 		assert(i < MAX_SIZE);
 		return _stack[i];
 	}
+
 	const T &operator[](size_type i) const {
 		assert(i < MAX_SIZE);
 		return _stack[i];
 	}
+
 protected:
-	T	_stack[MAX_SIZE];
-	size_type	_size;
+	T         _stack[MAX_SIZE];
+	size_type _size;
 };
 
 
@@ -83,7 +92,7 @@ protected:
 template<class T>
 class Stack {
 private:
-	Array<T>	_stack;
+	Array<T> _stack;
 
 public:
 	typedef typename Array<T>::size_type size_type;
@@ -94,29 +103,37 @@ public:
 	bool empty() const {
 		return _stack.empty();
 	}
+
 	void clear() {
 		_stack.clear();
 	}
+
 	void push(const T &x) {
 		_stack.push_back(x);
 	}
+
 	T &top() {
 		return _stack.back();
 	}
+
 	const T &top() const {
 		return _stack.back();
 	}
+
 	T pop() {
 		T tmp = _stack.back();
 		_stack.pop_back();
 		return tmp;
 	}
+
 	size_type size() const {
 		return _stack.size();
 	}
+
 	T &operator[](size_type i) {
 		return _stack[i];
 	}
+
 	const T &operator[](size_type i) const {
 		return _stack[i];
 	}


Commit: 5eabc4a2f34c7fc734bc56894acbae2fe9e85807
    https://github.com/scummvm/scummvm/commit/5eabc4a2f34c7fc734bc56894acbae2fe9e85807
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-22T11:10:04-08:00

Commit Message:
COMMON: Add a size_type to List.

Changed paths:
    common/list.h



diff --git a/common/list.h b/common/list.h
index 044b9d7..9792042 100644
--- a/common/list.h
+++ b/common/list.h
@@ -43,6 +43,7 @@ public:
 	typedef ListInternal::ConstIterator<t_T>	const_iterator;
 
 	typedef t_T value_type;
+	typedef uint size_type;
 
 public:
 	List() {
@@ -181,8 +182,8 @@ public:
 		return *this;
 	}
 
-	uint size() const {
-		uint n = 0;
+	size_type size() const {
+		size_type n = 0;
 		for (const NodeBase *cur = _anchor._next; cur != &_anchor; cur = cur->_next)
 			++n;
 		return n;


Commit: dac6ac66ad0a5ce0d99e089dacad1d72929d0f42
    https://github.com/scummvm/scummvm/commit/dac6ac66ad0a5ce0d99e089dacad1d72929d0f42
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-22T11:13:33-08:00

Commit Message:
COMMON: Add a size_type to HashMap.

Changed paths:
    common/hashmap.h



diff --git a/common/hashmap.h b/common/hashmap.h
index 347ac1f..7cf5499 100644
--- a/common/hashmap.h
+++ b/common/hashmap.h
@@ -67,7 +67,7 @@ template<class T> class IteratorImpl;
 
 /**
  * HashMap<Key,Val> maps objects of type Key to objects of type Val.
- * For each used Key type, we need an "uint hashit(Key,uint)" function
+ * For each used Key type, we need an "size_type hashit(Key,size_type)" function
  * that computes a hash for the given Key object and returns it as an
  * an integer from 0 to hashsize-1, and also an "equality functor".
  * that returns true if if its two arguments are to be considered
@@ -80,6 +80,9 @@ template<class T> class IteratorImpl;
  */
 template<class Key, class Val, class HashFunc = Hash<Key>, class EqualFunc = EqualTo<Key> >
 class HashMap {
+public:
+	typedef uint size_type;
+
 private:
 
 	typedef HashMap<Key, Val, HashFunc, EqualFunc> HM_t;
@@ -111,9 +114,9 @@ private:
 #endif
 
 	Node **_storage;	///< hashtable of size arrsize.
-	uint _mask;		///< Capacity of the HashMap minus one; must be a power of two of minus one
-	uint _size;
-	uint _deleted; ///< Number of deleted elements (_dummyNodes)
+	size_type _mask;		///< Capacity of the HashMap minus one; must be a power of two of minus one
+	size_type _size;
+	size_type _deleted; ///< Number of deleted elements (_dummyNodes)
 
 	HashFunc _hash;
 	EqualFunc _equal;
@@ -146,9 +149,9 @@ private:
 	}
 
 	void assign(const HM_t &map);
-	uint lookup(const Key &key) const;
-	uint lookupAndCreateIfMissing(const Key &key);
-	void expandStorage(uint newCapacity);
+	size_type lookup(const Key &key) const;
+	size_type lookupAndCreateIfMissing(const Key &key);
+	void expandStorage(size_type newCapacity);
 
 #if !defined(__sgi) || defined(__GNUC__)
 	template<class T> friend class IteratorImpl;
@@ -168,11 +171,11 @@ private:
 	protected:
 		typedef const HashMap hashmap_t;
 
-		uint _idx;
+		size_type _idx;
 		hashmap_t *_hashmap;
 
 	protected:
-		IteratorImpl(uint idx, hashmap_t *hashmap) : _idx(idx), _hashmap(hashmap) {}
+		IteratorImpl(size_type idx, hashmap_t *hashmap) : _idx(idx), _hashmap(hashmap) {}
 
 		NodeType *deref() const {
 			assert(_hashmap != 0);
@@ -200,7 +203,7 @@ private:
 				_idx++;
 			} while (_idx <= _hashmap->_mask && (_hashmap->_storage[_idx] == 0 || _hashmap->_storage[_idx] == HASHMAP_DUMMY_NODE));
 			if (_idx > _hashmap->_mask)
-				_idx = (uint)-1;
+				_idx = (size_type)-1;
 
 			return *this;
 		}
@@ -247,41 +250,41 @@ public:
 	void erase(iterator entry);
 	void erase(const Key &key);
 
-	uint size() const { return _size; }
+	size_type size() const { return _size; }
 
 	iterator	begin() {
 		// Find and return the first non-empty entry
-		for (uint ctr = 0; ctr <= _mask; ++ctr) {
+		for (size_type ctr = 0; ctr <= _mask; ++ctr) {
 			if (_storage[ctr] && _storage[ctr] != HASHMAP_DUMMY_NODE)
 				return iterator(ctr, this);
 		}
 		return end();
 	}
 	iterator	end() {
-		return iterator((uint)-1, this);
+		return iterator((size_type)-1, this);
 	}
 
 	const_iterator	begin() const {
 		// Find and return the first non-empty entry
-		for (uint ctr = 0; ctr <= _mask; ++ctr) {
+		for (size_type ctr = 0; ctr <= _mask; ++ctr) {
 			if (_storage[ctr] && _storage[ctr] != HASHMAP_DUMMY_NODE)
 				return const_iterator(ctr, this);
 		}
 		return end();
 	}
 	const_iterator	end() const {
-		return const_iterator((uint)-1, this);
+		return const_iterator((size_type)-1, this);
 	}
 
 	iterator	find(const Key &key) {
-		uint ctr = lookup(key);
+		size_type ctr = lookup(key);
 		if (_storage[ctr])
 			return iterator(ctr, this);
 		return end();
 	}
 
 	const_iterator	find(const Key &key) const {
-		uint ctr = lookup(key);
+		size_type ctr = lookup(key);
 		if (_storage[ctr])
 			return const_iterator(ctr, this);
 		return end();
@@ -346,7 +349,7 @@ HashMap<Key, Val, HashFunc, EqualFunc>::HashMap(const HM_t &map) :
  */
 template<class Key, class Val, class HashFunc, class EqualFunc>
 HashMap<Key, Val, HashFunc, EqualFunc>::~HashMap() {
-	for (uint ctr = 0; ctr <= _mask; ++ctr)
+	for (size_type ctr = 0; ctr <= _mask; ++ctr)
 	  freeNode(_storage[ctr]);
 
 	delete[] _storage;
@@ -373,7 +376,7 @@ void HashMap<Key, Val, HashFunc, EqualFunc>::assign(const HM_t &map) {
 	// Simply clone the map given to us, one by one.
 	_size = 0;
 	_deleted = 0;
-	for (uint ctr = 0; ctr <= _mask; ++ctr) {
+	for (size_type ctr = 0; ctr <= _mask; ++ctr) {
 		if (map._storage[ctr] == HASHMAP_DUMMY_NODE) {
 			_storage[ctr] = HASHMAP_DUMMY_NODE;
 			_deleted++;
@@ -391,7 +394,7 @@ void HashMap<Key, Val, HashFunc, EqualFunc>::assign(const HM_t &map) {
 
 template<class Key, class Val, class HashFunc, class EqualFunc>
 void HashMap<Key, Val, HashFunc, EqualFunc>::clear(bool shrinkArray) {
-	for (uint ctr = 0; ctr <= _mask; ++ctr) {
+	for (size_type ctr = 0; ctr <= _mask; ++ctr) {
 		freeNode(_storage[ctr]);
 		_storage[ctr] = NULL;
 	}
@@ -414,13 +417,13 @@ void HashMap<Key, Val, HashFunc, EqualFunc>::clear(bool shrinkArray) {
 }
 
 template<class Key, class Val, class HashFunc, class EqualFunc>
-void HashMap<Key, Val, HashFunc, EqualFunc>::expandStorage(uint newCapacity) {
+void HashMap<Key, Val, HashFunc, EqualFunc>::expandStorage(size_type newCapacity) {
 	assert(newCapacity > _mask+1);
 
 #ifndef NDEBUG
-	const uint old_size = _size;
+	const size_type old_size = _size;
 #endif
-	const uint old_mask = _mask;
+	const size_type old_mask = _mask;
 	Node **old_storage = _storage;
 
 	// allocate a new array
@@ -432,7 +435,7 @@ void HashMap<Key, Val, HashFunc, EqualFunc>::expandStorage(uint newCapacity) {
 	memset(_storage, 0, newCapacity * sizeof(Node *));
 
 	// rehash all the old elements
-	for (uint ctr = 0; ctr <= old_mask; ++ctr) {
+	for (size_type ctr = 0; ctr <= old_mask; ++ctr) {
 		if (old_storage[ctr] == NULL || old_storage[ctr] == HASHMAP_DUMMY_NODE)
 			continue;
 
@@ -440,9 +443,9 @@ void HashMap<Key, Val, HashFunc, EqualFunc>::expandStorage(uint newCapacity) {
 		// Since we know that no key exists twice in the old table, we
 		// can do this slightly better than by calling lookup, since we
 		// don't have to call _equal().
-		const uint hash = _hash(old_storage[ctr]->_key);
-		uint idx = hash & _mask;
-		for (uint perturb = hash; _storage[idx] != NULL && _storage[idx] != HASHMAP_DUMMY_NODE; perturb >>= HASHMAP_PERTURB_SHIFT) {
+		const size_type hash = _hash(old_storage[ctr]->_key);
+		size_type idx = hash & _mask;
+		for (size_type perturb = hash; _storage[idx] != NULL && _storage[idx] != HASHMAP_DUMMY_NODE; perturb >>= HASHMAP_PERTURB_SHIFT) {
 			idx = (5 * idx + perturb + 1) & _mask;
 		}
 
@@ -460,10 +463,10 @@ void HashMap<Key, Val, HashFunc, EqualFunc>::expandStorage(uint newCapacity) {
 }
 
 template<class Key, class Val, class HashFunc, class EqualFunc>
-uint HashMap<Key, Val, HashFunc, EqualFunc>::lookup(const Key &key) const {
-	const uint hash = _hash(key);
-	uint ctr = hash & _mask;
-	for (uint perturb = hash; ; perturb >>= HASHMAP_PERTURB_SHIFT) {
+typename HashMap<Key, Val, HashFunc, EqualFunc>::size_type HashMap<Key, Val, HashFunc, EqualFunc>::lookup(const Key &key) const {
+	const size_type hash = _hash(key);
+	size_type ctr = hash & _mask;
+	for (size_type perturb = hash; ; perturb >>= HASHMAP_PERTURB_SHIFT) {
 		if (_storage[ctr] == NULL)
 			break;
 		if (_storage[ctr] == HASHMAP_DUMMY_NODE) {
@@ -491,13 +494,13 @@ uint HashMap<Key, Val, HashFunc, EqualFunc>::lookup(const Key &key) const {
 }
 
 template<class Key, class Val, class HashFunc, class EqualFunc>
-uint HashMap<Key, Val, HashFunc, EqualFunc>::lookupAndCreateIfMissing(const Key &key) {
-	const uint hash = _hash(key);
-	uint ctr = hash & _mask;
-	const uint NONE_FOUND = _mask + 1;
-	uint first_free = NONE_FOUND;
+typename HashMap<Key, Val, HashFunc, EqualFunc>::size_type HashMap<Key, Val, HashFunc, EqualFunc>::lookupAndCreateIfMissing(const Key &key) {
+	const size_type hash = _hash(key);
+	size_type ctr = hash & _mask;
+	const size_type NONE_FOUND = _mask + 1;
+	size_type first_free = NONE_FOUND;
 	bool found = false;
-	for (uint perturb = hash; ; perturb >>= HASHMAP_PERTURB_SHIFT) {
+	for (size_type perturb = hash; ; perturb >>= HASHMAP_PERTURB_SHIFT) {
 		if (_storage[ctr] == NULL)
 			break;
 		if (_storage[ctr] == HASHMAP_DUMMY_NODE) {
@@ -537,7 +540,7 @@ uint HashMap<Key, Val, HashFunc, EqualFunc>::lookupAndCreateIfMissing(const Key
 
 		// Keep the load factor below a certain threshold.
 		// Deleted nodes are also counted
-		uint capacity = _mask + 1;
+		size_type capacity = _mask + 1;
 		if ((_size + _deleted) * HASHMAP_LOADFACTOR_DENOMINATOR >
 		        capacity * HASHMAP_LOADFACTOR_NUMERATOR) {
 			capacity = capacity < 500 ? (capacity * 4) : (capacity * 2);
@@ -553,7 +556,7 @@ uint HashMap<Key, Val, HashFunc, EqualFunc>::lookupAndCreateIfMissing(const Key
 
 template<class Key, class Val, class HashFunc, class EqualFunc>
 bool HashMap<Key, Val, HashFunc, EqualFunc>::contains(const Key &key) const {
-	uint ctr = lookup(key);
+	size_type ctr = lookup(key);
 	return (_storage[ctr] != NULL);
 }
 
@@ -569,7 +572,7 @@ const Val &HashMap<Key, Val, HashFunc, EqualFunc>::operator[](const Key &key) co
 
 template<class Key, class Val, class HashFunc, class EqualFunc>
 Val &HashMap<Key, Val, HashFunc, EqualFunc>::getVal(const Key &key) {
-	uint ctr = lookupAndCreateIfMissing(key);
+	size_type ctr = lookupAndCreateIfMissing(key);
 	assert(_storage[ctr] != NULL);
 	return _storage[ctr]->_value;
 }
@@ -581,7 +584,7 @@ const Val &HashMap<Key, Val, HashFunc, EqualFunc>::getVal(const Key &key) const
 
 template<class Key, class Val, class HashFunc, class EqualFunc>
 const Val &HashMap<Key, Val, HashFunc, EqualFunc>::getVal(const Key &key, const Val &defaultVal) const {
-	uint ctr = lookup(key);
+	size_type ctr = lookup(key);
 	if (_storage[ctr] != NULL)
 		return _storage[ctr]->_value;
 	else
@@ -590,7 +593,7 @@ const Val &HashMap<Key, Val, HashFunc, EqualFunc>::getVal(const Key &key, const
 
 template<class Key, class Val, class HashFunc, class EqualFunc>
 void HashMap<Key, Val, HashFunc, EqualFunc>::setVal(const Key &key, const Val &val) {
-	uint ctr = lookupAndCreateIfMissing(key);
+	size_type ctr = lookupAndCreateIfMissing(key);
 	assert(_storage[ctr] != NULL);
 	_storage[ctr]->_value = val;
 }
@@ -599,7 +602,7 @@ template<class Key, class Val, class HashFunc, class EqualFunc>
 void HashMap<Key, Val, HashFunc, EqualFunc>::erase(iterator entry) {
 	// Check whether we have a valid iterator
 	assert(entry._hashmap == this);
-	const uint ctr = entry._idx;
+	const size_type ctr = entry._idx;
 	assert(ctr <= _mask);
 	Node * const node = _storage[ctr];
 	assert(node != NULL);
@@ -615,7 +618,7 @@ void HashMap<Key, Val, HashFunc, EqualFunc>::erase(iterator entry) {
 template<class Key, class Val, class HashFunc, class EqualFunc>
 void HashMap<Key, Val, HashFunc, EqualFunc>::erase(const Key &key) {
 
-	uint ctr = lookup(key);
+	size_type ctr = lookup(key);
 	if (_storage[ctr] == NULL)
 		return;
 


Commit: 442bcb7d3eb64f3fbde3ee5bd2b16e7c01bae469
    https://github.com/scummvm/scummvm/commit/442bcb7d3eb64f3fbde3ee5bd2b16e7c01bae469
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-22T11:20:55-08:00

Commit Message:
ALL: Fix some signed/unsigned comparison warnings.

Changed paths:
    engines/agi/saveload.cpp
    engines/gob/hotspots.cpp
    graphics/cursorman.cpp
    gui/gui-manager.cpp



diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp
index 00d6a1c..0ef6230 100644
--- a/engines/agi/saveload.cpp
+++ b/engines/agi/saveload.cpp
@@ -221,8 +221,8 @@ int AgiEngine::saveGame(const Common::String &fileName, const Common::String &de
 
 	// Save image stack
 
-	for (i = 0; i < _imageStack.size(); i++) {
-		ImageStackElement ise = _imageStack[i];
+	for (Common::Stack<ImageStackElement>::size_type j = 0; j < _imageStack.size(); ++j) {
+		const ImageStackElement &ise = _imageStack[j];
 		out->writeByte(ise.type);
 		out->writeSint16BE(ise.parm1);
 		out->writeSint16BE(ise.parm2);
diff --git a/engines/gob/hotspots.cpp b/engines/gob/hotspots.cpp
index 5e0af84..9a89f11 100644
--- a/engines/gob/hotspots.cpp
+++ b/engines/gob/hotspots.cpp
@@ -477,7 +477,7 @@ void Hotspots::call(uint16 offset) {
 
 	_shouldPush = true;
 
-	int16 stackSize = _stack.size();
+	Common::Stack<StackEntry>::size_type stackSize = _stack.size();
 
 	_vm->_inter->funcBlock(0);
 
diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp
index 1d4e482..425714e 100644
--- a/graphics/cursorman.cpp
+++ b/graphics/cursorman.cpp
@@ -31,10 +31,10 @@ DECLARE_SINGLETON(Graphics::CursorManager);
 namespace Graphics {
 
 CursorManager::~CursorManager() {
-	for (int i = 0; i < _cursorStack.size(); ++i)
+	for (Common::Stack<Cursor *>::size_type i = 0; i < _cursorStack.size(); ++i)
 		delete _cursorStack[i];
 	_cursorStack.clear();
-	for (int i = 0; i < _cursorPaletteStack.size(); ++i)
+	for (Common::Stack<Palette *>::size_type i = 0; i < _cursorPaletteStack.size(); ++i)
 		delete _cursorPaletteStack[i];
 	_cursorPaletteStack.clear();
 }
diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp
index e7f49e9..4fa60bf 100644
--- a/gui/gui-manager.cpp
+++ b/gui/gui-manager.cpp
@@ -188,7 +188,7 @@ bool GuiManager::loadNewTheme(Common::String id, ThemeEngine::GraphicsMode gfx,
 	}
 
 	// refresh all dialogs
-	for (int i = 0; i < _dialogStack.size(); ++i)
+	for (DialogStack::size_type i = 0; i < _dialogStack.size(); ++i)
 		_dialogStack[i]->reflowLayout();
 
 	// We need to redraw immediately. Otherwise
@@ -202,7 +202,6 @@ bool GuiManager::loadNewTheme(Common::String id, ThemeEngine::GraphicsMode gfx,
 }
 
 void GuiManager::redraw() {
-	int i;
 	ThemeEngine::ShadingStyle shading;
 
 	if (_redrawStatus == kRedrawDisabled || _dialogStack.empty())
@@ -223,7 +222,7 @@ void GuiManager::redraw() {
 			_theme->clearAll();
 			_theme->openDialog(true, ThemeEngine::kShadingNone);
 
-			for (i = 0; i < _dialogStack.size() - 1; i++)
+			for (DialogStack::size_type i = 0; i < _dialogStack.size() - 1; i++)
 				_dialogStack[i]->drawDialog();
 
 			_theme->finishBuffering();
@@ -515,7 +514,7 @@ void GuiManager::screenChange() {
 	_theme->refresh();
 
 	// refresh all dialogs
-	for (int i = 0; i < _dialogStack.size(); ++i) {
+	for (DialogStack::size_type i = 0; i < _dialogStack.size(); ++i) {
 		_dialogStack[i]->reflowLayout();
 	}
 	// We need to redraw immediately. Otherwise






More information about the Scummvm-git-logs mailing list