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); backlogl = log_backlogs(LINK(ic)->log);
while ((bl = list_remove_first(backlogl))) { 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); mylog(LOG_INFO, "backlogging: %s", bl);
write_lines(CONN(ic), write_lines(CONN(ic), bllines);
backlog_lines_from_last_mark(LINK(ic)->log, bl)); list_free(bllines);
free(bl); free(bl);
} }
list_free(backlogl); list_free(backlogl);

View File

@ -442,19 +442,20 @@ void list_free(list_t *t)
free(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; return;
if (src->first == NULL) { if (dest->first == NULL) {
src->first = dest->first; dest->first = src->first;
src->last = dest->last; dest->last = src->last;
src->first = src->last = NULL;
return; return;
} }
dest->first->prev = src->last; src->first->prev = dest->last;
src->last->next = dest->first; dest->last->next = src->first;
src->last = dest->last; dest->last = src->last;
free(dest); 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_item(list_iterator_t *ti);
void *list_it_remove(list_iterator_t *li); void *list_it_remove(list_iterator_t *li);
void list_free(list_t *t); void list_free(list_t *t);
void list_copy(list_t *src, list_t *dest); void list_append(list_t *dest, list_t *src);
/* dest must not be refed after wards */
void list_append(list_t *src, list_t *dest);
int list_is_empty(list_t *l); int list_is_empty(list_t *l);
void hash_init(hash_t *h, int); void hash_init(hash_t *h, int);