Files
donnyandClaude Fable 5.1 26f9baf9b4 core: import the rules core (ygopro-core 973672dc + fork patches)
The vendored ocgcore from the Unity repo (Tools/YGOLegacy/ocgcore at dev
HEAD). Upstream is nanahira/ygopro-core at 973672dc9ce7cb49f47173277ab1ad0e318b7593;
the seven files that differ from it carry the fork's core patches, already
applied: 0001 face-down Token setcode, 0004 effect damage step outside a
chain, 0008 Sandbox god mode, 0015 tag first seat holds the hand, 0022
attack preview, 0024 attack preview legality. Generated build/ output is
left out.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-14 20:58:16 -07:00

39 lines
874 B
C++

#ifndef LUA_MEM_TRACKER_H
#define LUA_MEM_TRACKER_H
#include <cstdlib>
#include <cstddef>
#include <lua.h>
#ifdef YGOPRO_LOG_LUA_MEMORY_SIZE
#include <ctime> // time_t
#include <cstdio> // FILE*, fopen, fprintf
#endif
class LuaMemTracker {
public:
LuaMemTracker(size_t mem_limit = 0);
~LuaMemTracker();
static void* AllocThunk(void* ud, void* ptr, size_t osize, size_t nsize);
void* Alloc(void* ptr, size_t osize, size_t nsize);
size_t get_total() const { return total_allocated; }
size_t get_limit() const { return limit; }
private:
#ifdef YGOPRO_LOG_LUA_MEMORY_SIZE
FILE* log_file = nullptr;
void write_log();
#endif
lua_Alloc real_alloc;
void* real_ud;
size_t total_allocated = 0;
size_t limit = 0;
#ifdef YGOPRO_LOG_LUA_MEMORY_SIZE
size_t max_used = 0; // for logging purposes, to track peak memory usage
#endif
};
#endif // LUA_MEM_TRACKER_H