MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / xs_serial_destructor

Function xs_serial_destructor

modules/io/serial/win/serial.c:112–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112void 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
140void xs_serial_constructor(xsMachine *the)
141{

Callers 2

serial.cFile · 0.70
xs_serial_closeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected