diff options
author | Eugene Sandulenko | 2004-08-12 21:33:59 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2004-08-12 21:33:59 +0000 |
commit | e31aa607306b7b32891d4dd65efe0c06e1c71793 (patch) | |
tree | 1430eded88cf461b2ec927c2c3aaea49f3d227e1 | |
parent | bca746e80211d1b28cddcb7a5791d8dd20984f11 (diff) | |
download | scummvm-rg350-e31aa607306b7b32891d4dd65efe0c06e1c71793.tar.gz scummvm-rg350-e31aa607306b7b32891d4dd65efe0c06e1c71793.tar.bz2 scummvm-rg350-e31aa607306b7b32891d4dd65efe0c06e1c71793.zip |
Fix compilation of remove_at() in array.h. It was never tested before.
Make stacks' pop() return top value, not just move stack pointer.
svn-id: r14565
-rw-r--r-- | common/array.h | 6 | ||||
-rw-r--r-- | common/stack.h | 9 |
2 files changed, 9 insertions, 6 deletions
diff --git a/common/array.h b/common/array.h index 9a40a392c4..6fde309ac4 100644 --- a/common/array.h +++ b/common/array.h @@ -78,11 +78,9 @@ public: _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--; diff --git a/common/stack.h b/common/stack.h index acc8ae6c89..add790d695 100644 --- a/common/stack.h +++ b/common/stack.h @@ -54,9 +54,12 @@ public: 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 @@ public: else return 0; } - void pop() { + T pop() { + T tmp = top(); _stack.remove_at(size() - 1); + return tmp; } int size() const { return _stack.size(); |