-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdestroy_blocks.c
31 lines (29 loc) · 1.21 KB
/
destroy_blocks.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* destroy_blocks.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fnacarel <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/14 20:39:58 by fnacarel #+# #+# */
/* Updated: 2023/01/15 11:08:43 by fnacarel ### ########.fr */
/* */
/* ************************************************************************** */
#include "./encoder.h"
/*
Destroy every block I create using shmget
*/
void destroy_blocks(void)
{
key_t key[8];
int shmid[8];
for (int i = 0; i < 8; i++)
key[i] = ftok(FILENAME, i);
for (int i = 0; i < 8; i++)
shmid[i] = shmget(key[i], 1, 0);
for (int i = 0; i < 8; i++)
{
if (shmid[i] != -1)
shmctl(shmid[i], IPC_RMID, NULL);
}
}