@ -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.