| 110 | } |
| 111 | |
| 112 | void xs_serial_destructor(void *data) |
| 113 | { |
| 114 | xsSerial s = data; |
| 115 | if (!s) return; |
| 116 | if (s->comm != INVALID_HANDLE_VALUE) { |
| 117 | PurgeComm(s->comm, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR); |
| 118 | CancelIoEx(s->comm, NULL); |
| 119 | CloseHandle(s->comm); |
| 120 | } |
| 121 | if (s->thread != INVALID_HANDLE_VALUE) { |
| 122 | WaitForSingleObject(s->thread, INFINITE); |
| 123 | CloseHandle(s->thread); |
| 124 | } |
| 125 | if (s->commEvent != INVALID_HANDLE_VALUE) |
| 126 | CloseHandle(s->commEvent); |
| 127 | if (s->readEvent != INVALID_HANDLE_VALUE) |
| 128 | CloseHandle(s->readEvent); |
| 129 | if (s->readJob) |
| 130 | ((xsSerialJob)s->readJob)->serial = NULL; |
| 131 | DeleteCriticalSection(&s->readCritical); |
| 132 | if (s->writeEvent != INVALID_HANDLE_VALUE) |
| 133 | CloseHandle(s->writeEvent); |
| 134 | if (s->writeJob) |
| 135 | ((xsSerialJob)s->writeJob)->serial = NULL; |
| 136 | DeleteCriticalSection(&s->writeCritical); |
| 137 | free(data); |
| 138 | } |
| 139 | |
| 140 | void xs_serial_constructor(xsMachine *the) |
| 141 | { |
no outgoing calls
no test coverage detected