X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=listati%2FSharedMem.c;h=872a5bc72532f4fc81a7a83dcb3699f64ba04174;hp=9f5b438525062302744cd2be227959896989741e;hb=d47f15496fa85c8ec22edcde608f2665ec5b95ae;hpb=b324b7a09e071b2f84a1849d109d4d14f27f44cd diff --git a/listati/SharedMem.c b/listati/SharedMem.c index 9f5b438..872a5bc 100644 --- a/listati/SharedMem.c +++ b/listati/SharedMem.c @@ -2,28 +2,28 @@ void * ShmCreate(key_t ipc_key, int shm_size, int perm, int fill) { void * shm_ptr; - int shm_id; /* ID of the IPC shared memory segment */ - shm_id = shmget(ipc_key, shm_size, IPC_CREAT|perm); /* get shm ID */ + int shm_id; /* ID of the IPC shared memory segment */ + shm_id = shmget(ipc_key, shm_size, IPC_CREAT|perm); /* get shm ID */ if (shm_id < 0) { return NULL; } - shm_ptr = shmat(shm_id, NULL, 0); /* map it into memory */ + shm_ptr = shmat(shm_id, NULL, 0); /* map it into memory */ if (shm_ptr < 0) { return NULL; } - memset((void *)shm_ptr, fill, shm_size); /* fill segment */ + memset((void *)shm_ptr, fill, shm_size); /* fill segment */ return shm_ptr; } /* Function ShmFind: Find a SysV shared memory segment */ void * ShmFind(key_t ipc_key, int shm_size) { void * shm_ptr; - int shm_id; /* ID of the SysV shared memory segment */ - shm_id = shmget(ipc_key, shm_size, 0); /* find shared memory ID */ + int shm_id; /* ID of the SysV shared memory segment */ + shm_id = shmget(ipc_key, shm_size, 0); /* find shared memory ID */ if (shm_id < 0) { return NULL; } - shm_ptr = shmat(shm_id, NULL, 0); /* map it into memory */ + shm_ptr = shmat(shm_id, NULL, 0); /* map it into memory */ if (shm_ptr < 0) { return NULL; } @@ -32,18 +32,18 @@ void * ShmFind(key_t ipc_key, int shm_size) /* Function ShmRemove: Schedule removal for a SysV shared memory segment */ int ShmRemove(key_t ipc_key, void * shm_ptr) { - int shm_id; /* ID of the SysV shared memory segment */ + int shm_id; /* ID of the SysV shared memory segment */ /* first detach segment */ if (shmdt(shm_ptr) < 0) { return -1; } /* schedule segment removal */ - shm_id = shmget(ipc_key, 0, 0); /* find shared memory ID */ + shm_id = shmget(ipc_key, 0, 0); /* find shared memory ID */ if (shm_id < 0) { if (errno == EIDRM) return 0; return -1; } - if (shmctl(shm_id, IPC_RMID, NULL) < 0) { /* ask for removal */ + if (shmctl(shm_id, IPC_RMID, NULL) < 0) { /* ask for removal */ if (errno == EIDRM) return 0; return -1; }