mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-15 08:47:56 +01:00
plug memory leak
This commit is contained in:
parent
5b4e35be10
commit
9c96397ece
1 changed files with 18 additions and 1 deletions
|
@ -679,6 +679,13 @@ addWithKey( XW_DUtilCtxt* dutil, XWEnv xwe, WSData* wsdp )
|
|||
return wsdp->resultKey;
|
||||
}
|
||||
|
||||
static void
|
||||
delWSDatum( DLHead* elem, void* closure )
|
||||
{
|
||||
XW_DUtilCtxt* dutil = (XW_DUtilCtxt*)closure;
|
||||
XP_FREEP( dutil->mpool, &elem );
|
||||
}
|
||||
|
||||
void
|
||||
dvc_onWebSendResult( XW_DUtilCtxt* dutil, XWEnv xwe, XP_U32 resultKey,
|
||||
XP_Bool succeeded, const XP_UCHAR* resultJson )
|
||||
|
@ -717,11 +724,19 @@ dvc_onWebSendResult( XW_DUtilCtxt* dutil, XWEnv xwe, XP_U32 resultKey,
|
|||
}
|
||||
|
||||
cJSON_Delete( result );
|
||||
XP_FREEP( dutil->mpool, &wsdp );
|
||||
delWSDatum( &wsdp->links, dutil );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
freeWSState( XW_DUtilCtxt* dutil, DevCtxt* dc )
|
||||
{
|
||||
pthread_mutex_lock( &dc->webSendMutex );
|
||||
dll_removeAll( &dc->webSendData->links, delWSDatum, dutil );
|
||||
pthread_mutex_unlock( &dc->webSendMutex );
|
||||
}
|
||||
|
||||
typedef struct _PhoniesMapState {
|
||||
XW_DUtilCtxt* dutil;
|
||||
const XP_UCHAR* isoCode;
|
||||
|
@ -1118,6 +1133,8 @@ dvc_cleanup( XW_DUtilCtxt* dutil, XWEnv xwe )
|
|||
{
|
||||
DevCtxt* dc = freePhonyState( dutil, xwe );
|
||||
|
||||
freeWSState( dutil, dc );
|
||||
|
||||
pthread_mutex_destroy( &dc->webSendMutex );
|
||||
|
||||
XP_FREEP( dutil->mpool, &dc );
|
||||
|
|
Loading…
Add table
Reference in a new issue