Skip to content

Commit

Permalink
Make owl_list_free_simple a special case of owl_list_cleanup.
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-by: Nelson Elhage <nelhage@mit.edu>
  • Loading branch information
andersk committed Mar 8, 2010
1 parent 8c59178 commit 5e5f08f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion aim.c
Expand Up @@ -1615,7 +1615,7 @@ static int faimtest_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...)
owl_list_append_element(&list, (void *)&SNs[i*(MAXSNLEN+1)]); owl_list_append_element(&list, (void *)&SNs[i*(MAXSNLEN+1)]);
} }
owl_function_aimsearch_results(address, &list); owl_function_aimsearch_results(address, &list);
owl_list_free_simple(&list); owl_list_cleanup(&list, NULL);
return(1); return(1);
} }


Expand Down
11 changes: 4 additions & 7 deletions list.c
Expand Up @@ -80,13 +80,10 @@ void owl_list_cleanup(owl_list *l, void (*elefree)(void *))
{ {
int i; int i;


for (i=0; i<l->size; i++) { if (elefree) {
(elefree)(l->list[i]); for (i = 0; i < l->size; i++) {
(elefree)(l->list[i]);
}
} }
owl_free(l->list); owl_free(l->list);
} }

void owl_list_free_simple(owl_list *l)
{
if (l->list) owl_free(l->list);
}
2 changes: 1 addition & 1 deletion message.c
Expand Up @@ -962,7 +962,7 @@ void owl_message_free(owl_message *m)
owl_free(p); owl_free(p);
} }


owl_list_free_simple(&(m->attributes)); owl_list_cleanup(&(m->attributes), NULL);


owl_message_invalidate_format(m); owl_message_invalidate_format(m);
} }
Expand Down
2 changes: 1 addition & 1 deletion messagelist.c
Expand Up @@ -81,7 +81,7 @@ int owl_messagelist_expunge(owl_messagelist *ml)
} }


/* free the old list */ /* free the old list */
owl_list_free_simple(&(ml->list)); owl_list_cleanup(&(ml->list), NULL);


/* copy the new list to the old list */ /* copy the new list to the old list */
memcpy(&(ml->list), &newlist, sizeof(owl_list)); memcpy(&(ml->list), &newlist, sizeof(owl_list));
Expand Down
4 changes: 2 additions & 2 deletions view.c
Expand Up @@ -37,7 +37,7 @@ void owl_view_recalculate(owl_view *v)
ml=&(v->ml); ml=&(v->ml);


/* nuke the old list */ /* nuke the old list */
owl_list_free_simple(&ml->list); owl_list_cleanup(&ml->list, NULL);
owl_messagelist_create(&(v->ml)); owl_messagelist_create(&(v->ml));


/* find all the messages we want */ /* find all the messages we want */
Expand Down Expand Up @@ -158,6 +158,6 @@ const char *owl_view_get_filtname(const owl_view *v)


void owl_view_free(owl_view *v) void owl_view_free(owl_view *v)
{ {
owl_list_free_simple(&v->ml.list); owl_list_cleanup(&v->ml.list, NULL);
if (v->name) owl_free(v->name); if (v->name) owl_free(v->name);
} }

0 comments on commit 5e5f08f

Please sign in to comment.