From 8b47a5b9f49d94192d9a4f077fdd22712fa90df6 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 22 Jun 2019 21:16:29 +0300 Subject: First commit of replay system --- src/templates.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/templates.h') diff --git a/src/templates.h b/src/templates.h index 65f92a2a..7da0b3d6 100644 --- a/src/templates.h +++ b/src/templates.h @@ -101,6 +101,27 @@ public: n++; return n; } + void ClearStorage(uint8 **flags, U **entries){ + delete[] flags; + delete[] entries; + *flags = nil; + *entries = nil; + } + void CopyBack(uint8 **flags, U **entries){ + memcpy(m_flags, *flags, sizeof(Flags)*m_size); + memcpy(m_entries, *entries, sizeof(U)*m_size); + debug("Size copied:%d (%d)", sizeof(U)*m_size, sizeof(Flags)*m_size); + m_allocPtr = 0; + ClearStorage(flags, entries); + debug("CopyBack:%d (/%d)", GetNoOfUsedSpaces(), m_size); /* Assumed inlining */ + } + void Store(uint8 **flags, U** entries){ + *flags = (Flags*)malloc(sizeof(Flags)*size); + *entries = (U*)malloc(sizeof(U)*size); + memcpy(*flags, m_flags, sizeof(Flags)*m_size); + memcpy(*entries, m_entries, sizeof(U)*m_size); + debug("Stored:%d (/%d)", GetNoOfUsedSpaces(), m_size); /* Assumed inlining */ + } }; template -- cgit v1.2.3