#include <stdio.h>#include <stdlib.h>#include <stdbool.h>#include <string.h>#include <sys/shm.h>#include "qDecoder.h"
Go to the source code of this file.
FunctionsTitleTestFour | |
| bool | qShmFree (int shmid) |
| void * | qShmGet (int shmid) |
| int | qShmGetId (const char *keyfile, int keyid) |
| int | qShmInit (const char *keyfile, int keyid, size_t size, bool ifexistdestroy) |
[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; }
Definition in file qShm.c.
1.5.7.1