Copy the protocol name and adjust the kill code in asyncprotocol

This commit is contained in:
Douglas Clowes
2014-08-22 17:10:31 +10:00
parent 47d3d0a7e8
commit 3ff6377f85
2 changed files with 16 additions and 9 deletions

View File

@@ -286,7 +286,6 @@ int AsyncProtocolAction(SConnection * pCon, SicsInterp * pSics,
void defaultKillPrivate(pAsyncProtocol p)
{
if (p->privateData) {
/* TODO: should we do anything? */
free(p->privateData);
}
}
@@ -295,15 +294,22 @@ void AsyncProtocolKill(void *pData)
{
pAsyncProtocol self = (pAsyncProtocol) pData;
int i;
if (self->pDes)
DeleteDescriptor(self->pDes);
if (self->sendTerminator != NULL)
free(self->sendTerminator);
for (i = 0; i < 10; ++i)
if (self->replyTerminator[i] != NULL)
free(self->replyTerminator[i]);
if (self->killPrivate)
self->killPrivate(self);
if (self->pDes)
DeleteDescriptor(self->pDes);
self->pDes = NULL;
if (self->protocolName)
free(self->protocolName);
self->protocolName = NULL;
if (self->sendTerminator != NULL)
free(self->sendTerminator);
self->sendTerminator = NULL;
for (i = 0; i < 10; ++i) {
if (self->replyTerminator[i] != NULL)
free(self->replyTerminator[i]);
self->replyTerminator[i] = NULL;
}
}
pAsyncProtocol AsyncProtocolCreate(SicsInterp * pSics,
@@ -338,6 +344,7 @@ pAsyncProtocol AsyncProtocolCreate(SicsInterp * pSics,
AsyncProtocolKill(self);
return NULL;
}
self->protocolName = strdup(protocolName);
self->sendCommand = defaultSendCommand;
self->handleInput = defaultHandleInput;
self->handleEvent = defaultHandleEvent;