|
Functions | |
| int | qShmInit (const char *keyfile, int keyid, size_t size, bool ifexistdestroy) |
| Initialize shared-memory. | |
| int | qShmGetId (const char *keyfile, int keyid) |
| Get shared memory identifier by keyfile and keyid for existing shared memory. | |
| void * | qShmGet (int shmid) |
| Get a pointer of shared memory. | |
| bool | qShmFree (int shmid) |
| De-allocate shared memory. | |
[your header file] struct SharedData { (... structrue definitions ...) } [shared memory creater] // create shared memory int shmid = qShmInit("/some/file/for/generating/unique/key", 's', sizeof(struct SharedData), true); if(shmid < 0) { printf("ERROR: Can't initialize shared memory.\n"); return -1; } // get shared memory pointer struct SharedData *sdata = (SharedData *)qShmGet(shmid); if(sdata == NULL) { printf("ERROR: Can't get shared memory.\n"); return -1; } [shared memory user] // get shared memory id int shmid = qShmGetId("/some/file/for/generating/unique/key", 's'); if(shmid < 0) { printf("ERROR: Can't get shared memory id.\n"); return -1; } // get shared memory pointer struct SharedData *sdata = (SharedData *)qShmGet(shmid); if(sdata == NULL) { printf("ERROR: Can't get shared memory.\n"); return -1; }
| int qShmInit | ( | const char * | keyfile, | |
| int | keyid, | |||
| size_t | size, | |||
| bool | ifexistdestroy | |||
| ) |
Initialize shared-memory.
| keyfile | seed for generating unique IPC key | |
| keyid | seed for generating unique IPC key | |
| size | size of shared memory | |
| ifexistdestroy | set to true to destroy if shared-memory already exists |
| int qShmGetId | ( | const char * | keyfile, | |
| int | keyid | |||
| ) |
Get shared memory identifier by keyfile and keyid for existing shared memory.
| keyfile | seed for generating unique IPC key | |
| keyid | seed for generating unique IPC key |
| void* qShmGet | ( | int | shmid | ) |
Get a pointer of shared memory.
| shmid | shared memory identifier |
| bool qShmFree | ( | int | shmid | ) |
De-allocate shared memory.
| shmid | shared memory identifier |
| [Home] [About] [Examples] [Changes] [Download] [SVN Repository] [Install] [Reference] |