From ae51c454cc593f102ca2fe6c7726c4fe5ba3f65f Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Sat, 30 Jan 2021 19:40:29 +0200 Subject: [PATCH] Update sqratArray.h Use recently the new squirrel API function. --- module/Sqrat/sqratArray.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/module/Sqrat/sqratArray.h b/module/Sqrat/sqratArray.h index 27324935..82ad8c0c 100644 --- a/module/Sqrat/sqratArray.h +++ b/module/Sqrat/sqratArray.h @@ -504,6 +504,22 @@ public: return *this; } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// Reallocates the Array + /// + /// \param newcap Desired capacity of the Array in number of elements + /// + /// \return The Array itself so the call can be chained + /// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ArrayBase& Reserve(const SQInteger newcap) { + HSQUIRRELVM vm = SqVM(); + sq_pushobject(vm, GetObj()); + sq_arrayreserve(vm, -1, newcap); + sq_pop(vm,1); // pop array + return *this; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Reverses the elements of the array in place ///