| 175 | } |
| 176 | |
| 177 | static void free_hid_device(hid_device *dev) |
| 178 | { |
| 179 | if (!dev) |
| 180 | return; |
| 181 | |
| 182 | /* Delete any input reports still left over. */ |
| 183 | struct input_report *rpt = dev->input_reports; |
| 184 | while (rpt) { |
| 185 | struct input_report *next = rpt->next; |
| 186 | free(rpt->data); |
| 187 | free(rpt); |
| 188 | rpt = next; |
| 189 | } |
| 190 | |
| 191 | /* Free the string and the report buffer. The check for NULL |
| 192 | is necessary here as CFRelease() doesn't handle NULL like |
| 193 | free() and others do. */ |
| 194 | if (dev->run_loop_mode) |
| 195 | CFRelease(dev->run_loop_mode); |
| 196 | if (dev->source) |
| 197 | CFRelease(dev->source); |
| 198 | free(dev->input_report_buf); |
| 199 | hid_free_enumeration(dev->device_info); |
| 200 | |
| 201 | /* Clean up the thread objects */ |
| 202 | pthread_barrier_destroy(&dev->shutdown_barrier); |
| 203 | pthread_barrier_destroy(&dev->barrier); |
| 204 | pthread_cond_destroy(&dev->condition); |
| 205 | pthread_mutex_destroy(&dev->mutex); |
| 206 | |
| 207 | /* Free the structure itself. */ |
| 208 | free(dev); |
| 209 | } |
| 210 | |
| 211 | |
| 212 | /* The caller must free the returned string with free(). */ |
no test coverage detected