1
0
forked from bip/bip

Fix leak + cleanup list_append.

Thanks to TheMIROn for spotting the leak.
This commit is contained in:
Arnaud Cornet 2008-12-28 14:45:44 +01:00
parent 8693044511
commit 24110a58dc
3 changed files with 15 additions and 14 deletions

View File

@ -672,9 +672,11 @@ static void irc_cli_backlog(struct link_client *ic)
backlogl = log_backlogs(LINK(ic)->log);
while ((bl = list_remove_first(backlogl))) {
list_t *bllines;
bllines = backlog_lines_from_last_mark(LINK(ic)->log, bl);
mylog(LOG_INFO, "backlogging: %s", bl);
write_lines(CONN(ic),
backlog_lines_from_last_mark(LINK(ic)->log, bl));
write_lines(CONN(ic), bllines);
list_free(bllines);
free(bl);
}
list_free(backlogl);

View File

@ -442,19 +442,20 @@ void list_free(list_t *t)
free(t);
}
void list_append(list_t *src, list_t *dest)
void list_append(list_t *dest, list_t *src)
{
if (dest->last == NULL)
if (src->last == NULL)
return;
if (src->first == NULL) {
src->first = dest->first;
src->last = dest->last;
if (dest->first == NULL) {
dest->first = src->first;
dest->last = src->last;
src->first = src->last = NULL;
return;
}
dest->first->prev = src->last;
src->last->next = dest->first;
src->last = dest->last;
free(dest);
src->first->prev = dest->last;
dest->last->next = src->first;
dest->last = src->last;
src->first = src->last = NULL;
}
/*

View File

@ -112,9 +112,7 @@ void list_it_next(list_iterator_t *ti);
void *list_it_item(list_iterator_t *ti);
void *list_it_remove(list_iterator_t *li);
void list_free(list_t *t);
void list_copy(list_t *src, list_t *dest);
/* dest must not be refed after wards */
void list_append(list_t *src, list_t *dest);
void list_append(list_t *dest, list_t *src);
int list_is_empty(list_t *l);
void hash_init(hash_t *h, int);