~ segfault bug fix on getPixel
This commit is contained in:
parent
511f04edae
commit
82bab57e98
@ -60,18 +60,26 @@ namespace vkvm {
|
|||||||
unlockSharedMemory();
|
unlockSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *getLocalMemory(){
|
||||||
|
if (localSharedMemory.empty()) {
|
||||||
|
constexpr int kilo = 1024;
|
||||||
|
localSharedMemory.resize(impl.sharedMemorySize);
|
||||||
|
}
|
||||||
|
return &localSharedMemory[0];
|
||||||
|
}
|
||||||
|
|
||||||
auto getSharedMemory() -> char * {
|
auto getSharedMemory() -> char * {
|
||||||
int shmId = shmget(impl.sharedMemoryKey, 0, 0);
|
int shmId = shmget(impl.sharedMemoryKey, 0, 0);
|
||||||
if (shmId < 0) {
|
if (shmId < 0) {
|
||||||
//using a local buffer for shared memory testing
|
//using a local buffer for shared memory testing
|
||||||
if (localSharedMemory.empty()) {
|
return getLocalMemory();
|
||||||
initSemaphore();
|
}
|
||||||
constexpr int kilo = 1024;
|
char *ptr = static_cast<char *>(shmat(shmId, nullptr, 0));
|
||||||
localSharedMemory.resize(impl.sharedMemorySize * kilo);
|
if((size_t)ptr == (size_t)-1){
|
||||||
}
|
return getLocalMemory();
|
||||||
return &localSharedMemory[0];
|
}else{
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
return static_cast<char *>(shmat(shmId, nullptr, 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto getSharedMemory(char *address, int size, int offset) -> void {
|
auto getSharedMemory(char *address, int size, int offset) -> void {
|
||||||
|
Loading…
Reference in New Issue
Block a user