to_guliang
2nd June 2010, 01:59
I have some question to the following code:
int size = buffer.size();
if (!sharedMemory.create(size)) {
ui.label->setText(tr("Unable to create shared memory segment."));
return;
}
sharedMemory.lock();
char *to = (char*)sharedMemory.data();
const char *from = buffer.data().data();
memcpy(to, from, qMin(sharedMemory.size(), size));
sharedMemory.unlock();
1.
sharedMemory.create(size)Creates a shared memory segment of size bytes,Why sharedMemory.size() != size?
2.In addition, it seems like not sure about which one is big between sharedMemory.size() and
size(qMin(sharedMemory.size(), size)) ?
thanks very much for any advice!
int size = buffer.size();
if (!sharedMemory.create(size)) {
ui.label->setText(tr("Unable to create shared memory segment."));
return;
}
sharedMemory.lock();
char *to = (char*)sharedMemory.data();
const char *from = buffer.data().data();
memcpy(to, from, qMin(sharedMemory.size(), size));
sharedMemory.unlock();
1.
sharedMemory.create(size)Creates a shared memory segment of size bytes,Why sharedMemory.size() != size?
2.In addition, it seems like not sure about which one is big between sharedMemory.size() and
size(qMin(sharedMemory.size(), size)) ?
thanks very much for any advice!