l3cfg: factor out _obj_state_data_new() for creating object state

Will be used next.
This commit is contained in:
Fernando Fernandez Mancera
2023-11-24 14:46:27 +01:00
parent 02efd96396
commit ffe22c498f

View File

@@ -1008,6 +1008,21 @@ out:
nm_assert_obj_state(self, obj_state);
}
static void
_obj_states_track_new(NML3Cfg *self, const NMPObject *obj)
{
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
ObjStateData *obj_state;
obj_state = _obj_state_data_new(
obj,
nm_platform_lookup_obj(self->priv.platform, NMP_CACHE_ID_TYPE_OBJECT_TYPE, obj));
c_list_link_tail(&self->priv.p->obj_state_lst_head, &obj_state->os_lst);
g_hash_table_add(self->priv.p->obj_state_hash, obj_state);
_LOGD("obj-state: track: %s", _obj_state_data_to_string(obj_state, sbuf, sizeof(sbuf)));
nm_assert_obj_state(self, obj_state);
}
static void
_obj_states_update_all(NML3Cfg *self)
{
@@ -1052,16 +1067,7 @@ _obj_states_update_all(NML3Cfg *self)
obj_state = g_hash_table_lookup(self->priv.p->obj_state_hash, &obj);
if (!obj_state) {
obj_state =
_obj_state_data_new(obj,
nm_platform_lookup_obj(self->priv.platform,
NMP_CACHE_ID_TYPE_OBJECT_TYPE,
obj));
c_list_link_tail(&self->priv.p->obj_state_lst_head, &obj_state->os_lst);
g_hash_table_add(self->priv.p->obj_state_hash, obj_state);
_LOGD("obj-state: track: %s",
_obj_state_data_to_string(obj_state, sbuf, sizeof(sbuf)));
nm_assert_obj_state(self, obj_state);
_obj_states_track_new(self, obj);
continue;
}