@@ -1970,6 +1970,27 @@ hwloc__xml_export_safestrdup(const char *old)
1970
1970
return new ;
1971
1971
}
1972
1972
1973
+ static void
1974
+ hwloc__xml_export_info_attr_safe (hwloc__xml_export_state_t state , const char * name , const char * value )
1975
+ {
1976
+ struct hwloc__xml_export_state_s childstate ;
1977
+ state -> new_child (state , & childstate , "info" );
1978
+ childstate .new_prop (& childstate , "name" , name );
1979
+ childstate .new_prop (& childstate , "value" , value );
1980
+ childstate .end_object (& childstate , "info" );
1981
+ }
1982
+
1983
+ static void
1984
+ hwloc__xml_export_info_attr (hwloc__xml_export_state_t state , const char * _name , const char * _value )
1985
+ {
1986
+ char * name = hwloc__xml_export_safestrdup (_name );
1987
+ char * value = hwloc__xml_export_safestrdup (_value );
1988
+ if (name && value )
1989
+ hwloc__xml_export_info_attr_safe (state , name , value );
1990
+ free (name );
1991
+ free (value );
1992
+ }
1993
+
1973
1994
static void
1974
1995
hwloc__xml_export_object_contents (hwloc__xml_export_state_t state , hwloc_topology_t topology , hwloc_obj_t obj , unsigned long flags )
1975
1996
{
@@ -2123,19 +2144,8 @@ hwloc__xml_export_object_contents (hwloc__xml_export_state_t state, hwloc_topolo
2123
2144
break ;
2124
2145
}
2125
2146
2126
- for (i = 0 ; i < obj -> infos_count ; i ++ ) {
2127
- char * name = hwloc__xml_export_safestrdup (obj -> infos [i ].name );
2128
- char * value = hwloc__xml_export_safestrdup (obj -> infos [i ].value );
2129
- if (name && value ) {
2130
- struct hwloc__xml_export_state_s childstate ;
2131
- state -> new_child (state , & childstate , "info" );
2132
- childstate .new_prop (& childstate , "name" , name );
2133
- childstate .new_prop (& childstate , "value" , value );
2134
- childstate .end_object (& childstate , "info" );
2135
- }
2136
- free (name );
2137
- free (value );
2138
- }
2147
+ for (i = 0 ; i < obj -> infos_count ; i ++ )
2148
+ hwloc__xml_export_info_attr (state , obj -> infos [i ].name , obj -> infos [i ].value );
2139
2149
if (obj -> userdata && topology -> userdata_export_cb )
2140
2150
topology -> userdata_export_cb ((void * ) state , topology , obj );
2141
2151
}
@@ -2428,17 +2438,8 @@ hwloc__xml_export_cpukinds(hwloc__xml_export_state_t state, hwloc_topology_t top
2428
2438
cstate .new_prop (& cstate , "forced_efficiency" , tmp );
2429
2439
}
2430
2440
2431
- for (j = 0 ; j < kind -> nr_infos ; j ++ ) {
2432
- char * name = hwloc__xml_export_safestrdup (kind -> infos [j ].name );
2433
- char * value = hwloc__xml_export_safestrdup (kind -> infos [j ].value );
2434
- struct hwloc__xml_export_state_s istate ;
2435
- cstate .new_child (& cstate , & istate , "info" );
2436
- istate .new_prop (& istate , "name" , name );
2437
- istate .new_prop (& istate , "value" , value );
2438
- istate .end_object (& istate , "info" );
2439
- free (name );
2440
- free (value );
2441
- }
2441
+ for (j = 0 ; j < kind -> nr_infos ; j ++ )
2442
+ hwloc__xml_export_info_attr (& cstate , kind -> infos [j ].name , kind -> infos [j ].value );
2442
2443
2443
2444
cstate .end_object (& cstate , "cpukind" );
2444
2445
}
0 commit comments