MCPcopy Create free account
hub / github.com/MergHQ/CRYENGINE / custom_lua_alloc

Function custom_lua_alloc

Code/CryEngine/CryScriptSystem/ScriptSystem.cpp:218–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216 }
217
218 void* custom_lua_alloc(void* ud, void* ptr, size_t osize, size_t nsize)
219 {
220#if USE_RAW_LUA_ALLOCS
221 return _LuaRealloc(ptr, nsize);
222#else
223 MEMSTAT_CONTEXT(EMemStatContextTypes::MSC_LUA, 0, "Lua");
224 ScopedSwitchToGlobalHeap toGlobalHeap;
225
226 if (g_dumpStackOnAlloc)
227 DumpCallStack(g_LStack);
228
229 #if !defined(NOT_USE_CRY_MEMORY_MANAGER) && !defined(_DEBUG)
230 void* ret = gLuaAlloc.re_alloc(ptr, osize, nsize);
231 return ret;
232 #endif
233
234 (void)ud;
235 (void)osize;
236 if (nsize == 0)
237 {
238 free(ptr);
239 return NULL;
240 }
241 else
242 return realloc(ptr, nsize);
243
244#endif // USE_RAW_LUA_ALLOCS
245 }
246 static int cutsom_lua_panic(lua_State* L)
247 {
248 ScriptWarning("PANIC: unprotected error during Lua-API call\nLua error string: '%s'", lua_tostring(L, -1));

Callers

nothing calls this directly

Calls 2

DumpCallStackFunction · 0.85
re_allocMethod · 0.80

Tested by

no test coverage detected