~ only set default values if using localSharedMemory

This commit is contained in:
Julian Hinxlage 2019-12-18 12:42:01 +01:00
parent 12b8c74330
commit f231598aa0
3 changed files with 9 additions and 5 deletions

View File

@ -19,8 +19,6 @@ namespace vkvm {
int semId;
struct sembuf semaphore;
std::vector<char> localSharedMemory;
auto initSemaphore() -> int {
/* Testen, ob das Semaphor bereits existiert */
semId = semget(SEM_KEY, 0, IPC_PRIVATE);
@ -64,11 +62,11 @@ namespace vkvm {
givenWarning = true;
log(LogLevel::WARNING, "no shared memory found, using local memory instead!");
}
if (localSharedMemory.empty()) {
if (impl.localSharedMemory.empty()) {
constexpr int kilo = 1024;
localSharedMemory.resize(impl.sharedMemorySize * kilo);
impl.localSharedMemory.resize(impl.sharedMemorySize * kilo);
}
return &localSharedMemory[0];
return &impl.localSharedMemory[0];
}
auto getSharedMemory() -> char * {

View File

@ -11,6 +11,11 @@ namespace vkvm {
auto setDefaultValues() -> void {
impl.localMemoryWarn = false;
if (getSharedMemory() != nullptr) {
if (!impl.localSharedMemory.empty()) {
if(getSharedMemory() == &impl.localSharedMemory[0]){
return;
}
}
setMode(GraphicMode::RGB);
setCharactersPerRow(60);
setCharactersPerColumn(20);

View File

@ -61,6 +61,7 @@ constexpr int keyboardBufferSize = 16;
std::vector<std::function<void()>> eventTable;
bool localMemoryWarn = true;
char *sharedMemory = nullptr;
std::vector<char> localSharedMemory;
};
extern Impl impl;