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