~ fixed shared memory access error
This commit is contained in:
parent
cc7e3e09ad
commit
23b5224946
|
@ -75,6 +75,9 @@ namespace vkvm {
|
|||
}
|
||||
|
||||
auto getSharedMemory() -> char * {
|
||||
if(impl.sharedMemory != nullptr){
|
||||
return impl.sharedMemory;
|
||||
}
|
||||
int shmId = shmget(impl.sharedMemoryKey, 0, 0);
|
||||
if (shmId < 0) {
|
||||
//using a local buffer for shared memory testing
|
||||
|
@ -82,8 +85,10 @@ namespace vkvm {
|
|||
}
|
||||
char *ptr = static_cast<char *>(shmat(shmId, nullptr, 0));
|
||||
if((size_t)ptr == (size_t)-1){
|
||||
log(LogLevel::WARNING, strerror(errno));
|
||||
return getLocalMemory();
|
||||
}else{
|
||||
impl.sharedMemory = ptr;
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ constexpr int keyboardBufferSize = 16;
|
|||
int reservedSize = 1024; //NOLINT
|
||||
std::vector<std::function<void()>> eventTable;
|
||||
bool localMemoryWarn = true;
|
||||
char *sharedMemory = nullptr;
|
||||
};
|
||||
|
||||
extern Impl impl;
|
||||
|
|
|
@ -22,8 +22,8 @@ namespace vkvm {
|
|||
setMode(GraphicMode::RGB);
|
||||
setCharactersPerRow(60);// NOLINT
|
||||
setCharactersPerColumn(20);// NOLINT
|
||||
setHeight(600);// NOLINT
|
||||
setWidth(800);// NOLINT
|
||||
setHeight(60);// NOLINT
|
||||
setWidth(80);// NOLINT
|
||||
setMousePosition(42, 42);// NOLINT
|
||||
setBackgroundColor(black);
|
||||
setForegroundColor(white);
|
||||
|
|
Loading…
Reference in New Issue