File tree Expand file tree Collapse file tree 1 file changed +6
-36
lines changed Expand file tree Collapse file tree 1 file changed +6
-36
lines changed Original file line number Diff line number Diff line change @@ -81,46 +81,16 @@ static char *distances_transform_replace_newtype = NULL;
81
81
82
82
static void apply_infos (struct hwloc_infos_s * infos )
83
83
{
84
- unsigned i , j ;
85
84
if (clearinfos ) {
86
- /* this may be considered dangerous, applications should not modify objects directly */
87
- for (i = 0 ; i < infos -> count ; i ++ ) {
88
- struct hwloc_info_s * info = & infos -> array [i ];
89
- free (info -> name );
90
- free (info -> value );
91
- }
92
- free (infos -> array );
93
- infos -> array = NULL ;
94
- infos -> count = 0 ;
95
- infos -> allocated = 0 ;
85
+ hwloc_modify_infos (infos , HWLOC_MODIFY_INFOS_OP_REMOVE , NULL , NULL );
96
86
}
97
87
if (infoname ) {
98
88
if (replaceinfos ) {
99
- /* this may be considered dangerous, applications should not modify objects directly */
100
- for (i = 0 , j = 0 ; i < infos -> count ; i ++ ) {
101
- struct hwloc_info_s * info = & infos -> array [i ];
102
- if (!strcmp (infoname , info -> name )) {
103
- /* remove info */
104
- free (info -> name );
105
- info -> name = NULL ;
106
- free (info -> value );
107
- } else {
108
- if (i != j ) {
109
- /* shift info to where it belongs */
110
- infos -> array [j ].name = info -> name ;
111
- infos -> array [j ].value = info -> value ;
112
- }
113
- j ++ ;
114
- }
115
- }
116
- infos -> count = j ;
117
- if (!j ) {
118
- free (infos -> array );
119
- infos -> array = NULL ;
120
- infos -> allocated = 0 ;
121
- }
122
- }
123
- if (infovalue )
89
+ if (infovalue )
90
+ hwloc_modify_infos (infos , HWLOC_MODIFY_INFOS_OP_REPLACE , infoname , infovalue );
91
+ else
92
+ hwloc_modify_infos (infos , HWLOC_MODIFY_INFOS_OP_REMOVE , infoname , NULL );
93
+ } else
124
94
hwloc_modify_infos (infos , HWLOC_MODIFY_INFOS_OP_ADD , infoname , infovalue );
125
95
}
126
96
}
You can’t perform that action at this time.
0 commit comments