1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-23 02:13:01 +01:00

fix another potential memory leak

This commit is contained in:
Andriy Voskoboinyk 2014-09-05 13:17:10 +03:00
parent a862874740
commit 667410e879

View File

@ -107,15 +107,6 @@ static void line_info_root_fwd(struct history *hst)
hst->line_root = tmp;
}
/* adds a line_info line to queue */
static void line_info_add_queue(struct history *hst, struct line_info *line)
{
if (hst->queue_sz >= MAX_QUEUE)
return;
hst->queue[hst->queue_sz++] = line;
}
/* returns ptr to queue item 0 and removes it from queue */
static struct line_info *line_info_ret_queue(struct history *hst)
{
@ -140,6 +131,10 @@ void line_info_add(ToxWindow *self, char *tmstmp, char *name1, char *name2, uint
uint8_t colour, const char *msg, ...)
{
struct history *hst = self->chatwin->hst;
if (hst->queue_sz >= MAX_QUEUE)
return;
struct line_info *new_line = calloc(1, sizeof(struct line_info));
if (new_line == NULL)
@ -205,7 +200,7 @@ void line_info_add(ToxWindow *self, char *tmstmp, char *name1, char *name2, uint
new_line->bold = bold;
new_line->colour = colour;
line_info_add_queue(hst, new_line);
hst->queue[hst->queue_sz++] = new_line;
}
/* adds a single queue item to hst if possible. only called once per call to line_info_print() */