Manage memory with higher level constructs

This commit is contained in:
Chris Thrasher 2023-10-22 23:37:02 -05:00
parent 5cf740fd93
commit 13dd9f59cf
2 changed files with 6 additions and 5 deletions

View File

@ -500,9 +500,9 @@ JNIEXPORT void ANativeActivity_onCreate(ANativeActivity* activity, void* savedSt
if (savedState != nullptr)
{
states->savedState = std::malloc(savedStateSize);
states->savedStateSize = savedStateSize;
std::memcpy(states->savedState, savedState, savedStateSize);
const auto* begin = static_cast<const std::byte*>(savedState);
const auto* end = begin + savedStateSize;
states->savedState.assign(begin, end);
}
states->mainOver = false;

View File

@ -39,6 +39,8 @@
#include <unordered_map>
#include <vector>
#include <cstddef>
class SFML_SYSTEM_API LogcatStream : public std::streambuf
{
public:
@ -64,8 +66,7 @@ struct ActivityStates
EGLDisplay display{};
EglContext* context{};
void* savedState{};
std::size_t savedStateSize{};
std::vector<std::byte> savedState;
std::recursive_mutex mutex;