Free mailbox sems on free

master
Nick Krichevsky 2019-09-22 18:33:00 -04:00
parent c5735552a2
commit 3ff3a405c6
1 changed files with 4 additions and 0 deletions

View File

@ -47,6 +47,10 @@ void free_mailboxes() {
if (mailboxes == NULL) {
return;
}
for (int i = 0; i < num_mailboxes; i++) {
sem_destroy(&mailboxes[i].send_sem);
sem_destroy(&mailboxes[i].recv_sem);
}
free(mailboxes);
// Mark mailboxes as null so freeing is idempotent.