refactor: extract init_pages
This commit is contained in:
@@ -265,11 +265,24 @@ thread_create (const char *name, int priority,
|
||||
#ifdef USERPROG
|
||||
/* Initialize the thread's file descriptor table. */
|
||||
t->fd_counter = MINIMUM_USER_FD;
|
||||
bool success = hash_init (&t->open_files, fd_hash, fd_less, NULL);
|
||||
if (success)
|
||||
{
|
||||
success = hash_init (&t->child_results, process_result_hash,
|
||||
process_result_less, t);
|
||||
if (!success)
|
||||
hash_destroy (&t->open_files, NULL);
|
||||
#ifdef VM
|
||||
else
|
||||
{
|
||||
success = init_pages (&t->pages);
|
||||
if (!success)
|
||||
hash_destroy (&t->child_results, NULL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!hash_init (&t->open_files, fd_hash, fd_less, NULL)
|
||||
|| !hash_init (&t->child_results, process_result_hash,
|
||||
process_result_less, t)
|
||||
|| !hash_init (&t->pages, page_hash, page_less, NULL))
|
||||
if (!success)
|
||||
{
|
||||
palloc_free_page (t);
|
||||
free (t->result);
|
||||
|
||||
Reference in New Issue
Block a user