1
0
Fork 0

Fixed a few memory freeing issues which were probably only significant

on platforms with REALLY braindead malloc/free implementations
This commit is contained in:
shawarma 2005-03-23 21:55:00 +00:00
parent ea76865a4f
commit 941c83734a
3 changed files with 15 additions and 3 deletions

View File

@ -1053,8 +1053,8 @@ MmsMsg *mms_frombinary(Octstr *msg, Octstr *from)
if ((res = decode_msgbody(p, &_m)) < 0) { if ((res = decode_msgbody(p, &_m)) < 0) {
MmsMsg *msg = &_m; MmsMsg *msg = &_m;
if (msg->ismultipart && msg->body.l) if (msg->ismultipart && msg->body.l)
list_destroy(msg->body.l, (list_item_destructor_t *)mm_destroy); list_contents_destroy(msg->body.l, (list_item_destructor_t *)mm_destroy);
else if (msg->body.s) else if (msg->body.s)
octstr_destroy(msg->body.s); octstr_destroy(msg->body.s);
} }

View File

@ -38,7 +38,6 @@ static Octstr *cfg_getx(CfgGroup *grp, Octstr *item)
return v ? v : octstr_create(""); return v ? v : octstr_create("");
} }
static void *load_module(CfgGroup *grp, char *config_key, char *symbolname) static void *load_module(CfgGroup *grp, char *config_key, char *symbolname)
{ {
Octstr *s; Octstr *s;
@ -723,6 +722,17 @@ int mms_ind_send(Octstr *prov_cmd, Octstr *to)
return res; return res;
} }
void list_contents_destroy(List *list, list_item_destructor_t *destructor)
{
if (!list)
return;
int ll = list_len(list), lc;
for(lc=0;lc<ll;lc++)
destructor(list_get(list, lc));
list_delete(list, 0, ll);
}
static void addmmscname(Octstr *s, Octstr *myhostname) static void addmmscname(Octstr *s, Octstr *myhostname)
{ {

View File

@ -156,6 +156,8 @@ void base64_mimeparts(MIMEEntity *m);
void notify_prov_server(char *cmd, char *from, char *event, char *arg); void notify_prov_server(char *cmd, char *from, char *event, char *arg);
int mms_ind_send(Octstr *prov_cmd, Octstr *to); int mms_ind_send(Octstr *prov_cmd, Octstr *to);
/* Deletes all the elements of a list, but leaves the list itself alone. */
void list_contents_destroy(List *list, list_item_destructor_t *destructor);
/* Send this message to email recipient: Returns 0 on success 1 or 2 on profile error /* Send this message to email recipient: Returns 0 on success 1 or 2 on profile error
* (negate to get right one), -ve on some other error * (negate to get right one), -ve on some other error