fix memory leak caused by improper process destruction

This commit is contained in:
ІО-23 Шмуляр Олег 2025-03-18 19:10:38 +02:00
parent 63635b5f06
commit d7a8e8ae57
3 changed files with 11 additions and 1 deletions

View File

@ -27,6 +27,8 @@ struct Process *Process(size_t proc_id,
size_t total_pages_owned,
size_t ws_size);
void PROCESS_destroy(struct Process *p);
size_t PROCESS_run_for(struct Process *p, size_t time_bits);
void PROCESS_change_working_set(struct Process *p);

View File

@ -119,7 +119,7 @@ RUNQ_remove_current_process(void)
break;
}
free(tp);
PROCESS_destroy(tp);
runq->proc_amount--;
}

View File

@ -29,6 +29,14 @@ Process(size_t proc_id, size_t max_accesses, size_t total_pages_owned, size_t ws
return p;
}
void
PROCESS_destroy(struct Process *p)
{
free(p->pt);
free(p->ws);
free(p);
}
size_t
PROCESS_run_for(struct Process *p, size_t time_bits)
{