mirror of
https://github.com/paxed/dgamelaunch.git
synced 2025-07-28 16:14:33 +02:00
Move shmem freeing into it's own function
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@568 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
parent
ef9018dff1
commit
bf9db511f5
@ -537,6 +537,22 @@ shm_mk_keys(key_t *shm_key, key_t *shm_sem_key)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_SHMEM
|
||||||
|
int
|
||||||
|
shm_free()
|
||||||
|
{
|
||||||
|
key_t shm, sem;
|
||||||
|
int shm_id;
|
||||||
|
int shm_size = sizeof(struct dg_shm) + shm_n_games * sizeof(struct dg_shm_game);
|
||||||
|
shm_mk_keys(&shm, &sem);
|
||||||
|
if ((shm_id = shmget(shm, shm_size, 0644)) != -1) {
|
||||||
|
shmctl(shm_id, IPC_RMID, NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
shm_init(struct dg_shm **shm_dg_data, struct dg_shm_game **shm_dg_game)
|
shm_init(struct dg_shm **shm_dg_data, struct dg_shm_game **shm_dg_game)
|
||||||
{
|
{
|
||||||
@ -2336,23 +2352,16 @@ main (int argc, char** argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'S': /* Free the shared memory block */
|
case 'S': /* Free the shared memory block */
|
||||||
{
|
|
||||||
#ifdef USE_SHMEM
|
#ifdef USE_SHMEM
|
||||||
key_t shm, sem;
|
if (shm_free()) {
|
||||||
int shm_id;
|
|
||||||
int shm_size = sizeof(struct dg_shm) + shm_n_games * sizeof(struct dg_shm_game);
|
|
||||||
shm_mk_keys(&shm, &sem);
|
|
||||||
if ((shm_id = shmget(shm, shm_size, 0644)) != -1) {
|
|
||||||
shmctl(shm_id, IPC_RMID, NULL);
|
|
||||||
if (!silent) fprintf(stderr, "shmem block freed.\n");
|
|
||||||
} else {
|
|
||||||
if (!silent) fprintf(stderr, "nonexistent shmem block.\n");
|
if (!silent) fprintf(stderr, "nonexistent shmem block.\n");
|
||||||
|
} else {
|
||||||
|
if (!silent) fprintf(stderr, "shmem block freed.\n");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (!silent) fprintf(stderr, "warning: dgamelaunch was compiled without shmem.\n");
|
if (!silent) fprintf(stderr, "warning: dgamelaunch was compiled without shmem.\n");
|
||||||
#endif
|
#endif
|
||||||
graceful_exit(0);
|
graceful_exit(0);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'D': /* dump the shared memory block data */
|
case 'D': /* dump the shared memory block data */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user