Fixed some memory leaks
This commit is contained in:
parent
5f16ed5455
commit
daa808f9a2
@ -36,7 +36,7 @@ static int get_psk(struct cw_Conn *conn, const char *username, uint8_t ** psk,
|
|||||||
* @param default_cipher
|
* @param default_cipher
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int cw_setup_dtls(struct cw_Conn *conn, mavl_t cfg, const char *prefix,
|
int cw_setup_dtls(struct cw_Conn *conn, cw_Cfg_t * cfg, const char *prefix,
|
||||||
char *default_cipher)
|
char *default_cipher)
|
||||||
{
|
{
|
||||||
char key[CW_CFG_MAX_KEY_LEN];
|
char key[CW_CFG_MAX_KEY_LEN];
|
||||||
|
@ -71,23 +71,19 @@ static int cmp_machinestate(const void *state1, const void *state2)
|
|||||||
return s1->prevstate-s2->prevstate;
|
return s1->prevstate-s2->prevstate;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void msgdata_destroy(struct cw_MsgData *data)
|
|
||||||
|
static void del_mavl_msgdata(void * d)
|
||||||
{
|
{
|
||||||
if (!data)
|
struct cw_MsgData *data = (struct cw_MsgData *) d;
|
||||||
return;
|
|
||||||
if (data->elements_list)
|
if (data->elements_list)
|
||||||
mlist_destroy(data->elements_list);
|
mlist_destroy(data->elements_list);
|
||||||
|
|
||||||
if (data->elements_tree)
|
if (data->elements_tree)
|
||||||
mavl_destroy(data->elements_tree);
|
mavl_destroy(data->elements_tree);
|
||||||
|
|
||||||
|
if (data->mand_keys)
|
||||||
|
mlist_destroy(data->mand_keys);
|
||||||
|
|
||||||
free(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void del_mavl_msdgdata(void *d)
|
|
||||||
{
|
|
||||||
msgdata_destroy(d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -146,7 +142,7 @@ struct cw_MsgSet *cw_msgset_create()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* create mavl for messages */
|
/* create mavl for messages */
|
||||||
set->msgdata = mavl_create(cmp_msgdata, del_mavl_msdgdata,
|
set->msgdata = mavl_create(cmp_msgdata, del_mavl_msgdata,
|
||||||
sizeof(struct cw_MsgData));
|
sizeof(struct cw_MsgData));
|
||||||
if (set->msgdata == NULL) {
|
if (set->msgdata == NULL) {
|
||||||
cw_msgset_destroy(set);
|
cw_msgset_destroy(set);
|
||||||
@ -286,7 +282,6 @@ int cw_msgset_add(struct cw_MsgSet *set,
|
|||||||
|
|
||||||
struct cw_ElemHandler *handler;
|
struct cw_ElemHandler *handler;
|
||||||
struct cw_MsgDef *msgdef;
|
struct cw_MsgDef *msgdef;
|
||||||
|
|
||||||
/* Create mavl for all handlers */
|
/* Create mavl for all handlers */
|
||||||
for (handler = handlers; handler->id; handler++) {
|
for (handler = handlers; handler->id; handler++) {
|
||||||
cw_dbg(DBG_MOD, "Adding handler for element %d - %s - with key: %s",
|
cw_dbg(DBG_MOD, "Adding handler for element %d - %s - with key: %s",
|
||||||
@ -299,8 +294,8 @@ int cw_msgset_add(struct cw_MsgSet *set,
|
|||||||
struct cw_MsgData search;
|
struct cw_MsgData search;
|
||||||
struct cw_MsgData *msg;
|
struct cw_MsgData *msg;
|
||||||
int exists;
|
int exists;
|
||||||
|
|
||||||
/* add the message */
|
/* add the message */
|
||||||
|
memset(&search,0,sizeof(struct cw_MsgData));
|
||||||
search.type = msgdef->type;
|
search.type = msgdef->type;
|
||||||
|
|
||||||
msg = mavl_insert(set->msgdata, &search, &exists);
|
msg = mavl_insert(set->msgdata, &search, &exists);
|
||||||
@ -310,7 +305,7 @@ int cw_msgset_add(struct cw_MsgSet *set,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Look if message already exists */
|
/* Look if message already exists */
|
||||||
if (!exists) {
|
if (!exists ) {
|
||||||
/* message is fresh createt, initialize data */
|
/* message is fresh createt, initialize data */
|
||||||
msg->elements_tree = mavl_create(cmp_elemdata, NULL,
|
msg->elements_tree = mavl_create(cmp_elemdata, NULL,
|
||||||
sizeof(struct cw_ElemData));
|
sizeof(struct cw_ElemData));
|
||||||
@ -319,7 +314,6 @@ int cw_msgset_add(struct cw_MsgSet *set,
|
|||||||
msg->postprocess=NULL;
|
msg->postprocess=NULL;
|
||||||
msg->preprocess=NULL;
|
msg->preprocess=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Overwrite the found message */
|
/* Overwrite the found message */
|
||||||
if (msgdef->name != NULL)
|
if (msgdef->name != NULL)
|
||||||
msg->name = msgdef->name;
|
msg->name = msgdef->name;
|
||||||
|
Loading…
Reference in New Issue
Block a user