aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorEugene Sandulenko2016-05-23 16:08:17 +0200
committerEugene Sandulenko2016-05-23 16:36:34 +0200
commit3d89af272b718dd30a60f351149fde95958acfb0 (patch)
tree321cfb3f2282124a21a59f7c60a67497f9a78a89 /common
parent1f8667c5d949070035390531e4f10c0f945d7352 (diff)
downloadscummvm-rg350-3d89af272b718dd30a60f351149fde95958acfb0.tar.gz
scummvm-rg350-3d89af272b718dd30a60f351149fde95958acfb0.tar.bz2
scummvm-rg350-3d89af272b718dd30a60f351149fde95958acfb0.zip
COMMON: Fix SortedArray implementation for empty array
Diffstat (limited to 'common')
-rw-r--r--common/array.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/common/array.h b/common/array.h
index 869d79b68b..29a1ff8470 100644
--- a/common/array.h
+++ b/common/array.h
@@ -378,6 +378,11 @@ public:
* Inserts element at the sorted position.
*/
void insert(const T &element) {
+ if (!this->_size) {
+ this->insert_aux(this->_storage, &element, &element + 1);
+ return;
+ }
+
T *where = (T *)bsearchMin(element, this->front(), this->_size, sizeof(T), _comparator);
insert(where, element);
}