cwIo.cpp : Serial port server is now only started if a serial port is enabled.

Fixed memory leaks.
This commit is contained in:
kevin 2021-12-29 21:36:16 -05:00
parent 70c2aa5271
commit 321120af15

View File

@ -404,17 +404,19 @@ namespace cw
{
serialPortSrv::destroy(p->serialPortSrvH);
mem::free(p->serialA);
mem::release(p->serialA);
p->serialN = 0;
}
rc_t _serialPortStart( io_t* p )
{
rc_t rc;
rc_t rc = kOkRC;
if((rc =serialPortSrv::start( p->serialPortSrvH )) != kOkRC )
rc = cwLogError(rc,"The serial port server start failed.");
// the service is only started if at least one serial port is enabled
if( serialPort::portCount( serialPortSrv::serialHandle(p->serialPortSrvH) ) > 0 )
if((rc =serialPortSrv::start( p->serialPortSrvH )) != kOkRC )
rc = cwLogError(rc,"The serial port server start failed.");
return rc;
}
@ -1639,7 +1641,10 @@ namespace cw
if((rc = thread_mach::destroy(p->threadMachH)) != kOkRC )
return rc;
mem::free(p->timerA);
for(unsigned i=0; i<p->timerN; ++i)
mem::release(p->timerA[i].label);
mem::release(p->timerA);
p->timerN = 0;
_serialPortDestroy(p);
@ -1648,6 +1653,8 @@ namespace cw
midi::device::destroy(p->midiH);
sock::destroyMgr( p->sockH );
mem::release(p->sockA);
for(unsigned i=0; i<p->uiMapN; ++i)
@ -1657,6 +1664,7 @@ namespace cw
ui::ws::destroy(p->wsUiH);
// free the cfg object
if( p->cfg != nullptr )
p->cfg->free();