diff --git a/hphp/runtime/ext/ext_collections.cpp b/hphp/runtime/ext/ext_collections.cpp index 7e25d4427..cc7d54cd1 100644 --- a/hphp/runtime/ext/ext_collections.cpp +++ b/hphp/runtime/ext/ext_collections.cpp @@ -256,6 +256,21 @@ void c_Vector::t_resize(CVarRef sz, CVarRef value) { resize(intSz, val); } +void c_Vector::t_reserve(CVarRef sz) { + if (!sz.isInteger()) { + Object e(SystemLib::AllocInvalidArgumentExceptionObject( + "Parameter sz must be a non-negative integer")); + throw e; + } + int64_t intSz = sz.toInt64(); + if (intSz < 0) { + Object e(SystemLib::AllocInvalidArgumentExceptionObject( + "Parameter sz must be a non-negative integer")); + throw e; + } + reserve(intSz); +} + Object c_Vector::t_clear() { ++m_version; uint sz = m_size; diff --git a/hphp/runtime/ext/ext_collections.h b/hphp/runtime/ext/ext_collections.h index 2cd693855..45518089d 100644 --- a/hphp/runtime/ext/ext_collections.h +++ b/hphp/runtime/ext/ext_collections.h @@ -46,6 +46,7 @@ class c_Vector : public ExtObjectDataFlags