[Scummvm-cvs-logs] CVS: scummvm/common array.h,1.1,1.2 stack.h,1.2,1.3

Eugene Sandulenko sev at users.sourceforge.net
Thu Aug 12 14:35:03 CEST 2004


Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9606

Modified Files:
	array.h stack.h 
Log Message:
Fix compilation of remove_at() in array.h. It was never tested before.
Make stacks' pop() return top value, not just move stack pointer.


Index: array.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/array.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- array.h	9 Apr 2004 15:10:21 -0000	1.1
+++ array.h	12 Aug 2004 21:33:58 -0000	1.2
@@ -78,11 +78,9 @@
 		_size++;
 	}
 
-	T& remove_at(int idx) {
-		T& tmp;
-
+	T remove_at(int idx) {
 		assert(idx >= 0 && idx < _size);
-		tmp = _data[idx];
+		T tmp = _data[idx];
 		for (int i = idx; i < _size - 1; i++)
 			_data[i] = _data[i+1];
 		_size--;

Index: stack.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/stack.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- stack.h	5 May 2004 01:19:42 -0000	1.2
+++ stack.h	12 Aug 2004 21:33:59 -0000	1.3
@@ -54,9 +54,12 @@
 		else
 			return 0;
 	}
-	void pop() {
+	T pop() {
+		T tmp;
 		assert(_size > 0);
+		tmp = _stack[_size];
 		_stack[--_size] = 0;
+		return tmp;
 	}
 	int size() const {
 		return _size;
@@ -94,8 +97,10 @@
 		else
 			return 0;
 	}
-	void pop() {
+	T pop() {
+		T tmp = top();
 		_stack.remove_at(size() - 1);
+		return tmp;
 	}
 	int size() const {
 		return _stack.size();





More information about the Scummvm-git-logs mailing list