Driver: fortps: Simplify fort_pstree_proc_new()

This commit is contained in:
Nodir Temirkhodjaev 2023-04-13 19:10:46 +03:00
parent dab83b8e76
commit edf0ae45d8

View File

@ -428,14 +428,12 @@ static PFORT_PSNAME fort_pstree_add_service_name(
static PFORT_PSNODE fort_pstree_proc_new( static PFORT_PSNODE fort_pstree_proc_new(
PFORT_PSTREE ps_tree, PFORT_PSNAME ps_name, tommy_key_t pid_hash) PFORT_PSTREE ps_tree, PFORT_PSNAME ps_name, tommy_key_t pid_hash)
{ {
tommy_arrayof *procs = &ps_tree->procs;
tommy_hashdyn *procs_map = &ps_tree->procs_map;
tommy_hashdyn_node *proc_node = tommy_list_tail(&ps_tree->free_procs); tommy_hashdyn_node *proc_node = tommy_list_tail(&ps_tree->free_procs);
if (proc_node != NULL) { if (proc_node != NULL) {
tommy_list_remove_existing(&ps_tree->free_procs, proc_node); tommy_list_remove_existing(&ps_tree->free_procs, proc_node);
} else { } else {
tommy_arrayof *procs = &ps_tree->procs;
const UINT16 index = ps_tree->procs_n; const UINT16 index = ps_tree->procs_n;
tommy_arrayof_grow(procs, index + 1); tommy_arrayof_grow(procs, index + 1);
@ -443,7 +441,7 @@ static PFORT_PSNODE fort_pstree_proc_new(
proc_node = tommy_arrayof_ref(procs, index); proc_node = tommy_arrayof_ref(procs, index);
} }
tommy_hashdyn_insert(procs_map, proc_node, ps_name, pid_hash); tommy_hashdyn_insert(&ps_tree->procs_map, proc_node, ps_name, pid_hash);
++ps_tree->procs_n; ++ps_tree->procs_n;