|
@@ -169,27 +169,21 @@ bool impl_sysfs_free(light_device_enumerator_t *enumerator)
|
169
|
169
|
continue;
|
170
|
170
|
}
|
171
|
171
|
|
172
|
|
- // If the given device has a targets array that isnt NULL, iterate through it to free the targets, then free the array
|
173
|
|
- if(curr_device->targets != NULL)
|
|
172
|
+ for(uint64_t t = 0; t < curr_device->num_targets; t++)
|
174
|
173
|
{
|
175
|
|
- for(uint64_t t = 0; t < curr_device->num_targets; t++)
|
|
174
|
+ light_device_target_t *curr_target = curr_device->targets[t];
|
|
175
|
+
|
|
176
|
+ if(curr_target == NULL)
|
176
|
177
|
{
|
177
|
|
- light_device_target_t *curr_target = curr_device->targets[t];
|
178
|
|
-
|
179
|
|
- if(curr_target == NULL)
|
180
|
|
- {
|
181
|
|
- continue;
|
182
|
|
- }
|
183
|
|
-
|
184
|
|
- if(curr_target->device_target_data != NULL)
|
185
|
|
- {
|
186
|
|
- free(curr_target->device_target_data);
|
187
|
|
- }
|
188
|
|
-
|
189
|
|
- free(curr_target);
|
|
178
|
+ continue;
|
190
|
179
|
}
|
191
|
180
|
|
192
|
|
- free(curr_device->targets);
|
|
181
|
+ if(curr_target->device_target_data != NULL)
|
|
182
|
+ {
|
|
183
|
+ free(curr_target->device_target_data);
|
|
184
|
+ }
|
|
185
|
+
|
|
186
|
+ free(curr_target);
|
193
|
187
|
}
|
194
|
188
|
|
195
|
189
|
// If the given device has any device_data, free it
|
|
@@ -197,16 +191,13 @@ bool impl_sysfs_free(light_device_enumerator_t *enumerator)
|
197
|
191
|
{
|
198
|
192
|
free(curr_device->device_data);
|
199
|
193
|
}
|
200
|
|
-
|
|
194
|
+
|
|
195
|
+ light_dispose_device(curr_device);
|
|
196
|
+
|
201
|
197
|
// Free the device
|
202
|
198
|
free(curr_device);
|
203
|
199
|
}
|
204
|
200
|
|
205
|
|
- // Free the devices array
|
206
|
|
- free(enumerator->devices);
|
207
|
|
- enumerator->devices = NULL;
|
208
|
|
- enumerator->num_devices = 0;
|
209
|
|
-
|
210
|
201
|
return true;
|
211
|
202
|
}
|
212
|
203
|
|