Mercurial > hg > nnchat
comparison ui.c @ 507:e644d373afb9
Fix a memory leak.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 03 Jun 2012 06:31:52 +0300 |
parents | 8734a02a86ec |
children | f71c59cbc5a7 |
comparison
equal
deleted
inserted
replaced
506:8734a02a86ec | 507:e644d373afb9 |
---|---|
14 BOOL cursesInit = FALSE; | 14 BOOL cursesInit = FALSE; |
15 int cursorVisible = ERR, | 15 int cursorVisible = ERR, |
16 scrWidth, scrHeight; | 16 scrWidth, scrHeight; |
17 | 17 |
18 | 18 |
19 static void nn_line_free(void *ptr) | |
20 { | |
21 nn_line_t *line = (nn_line_t *) ptr; | |
22 if (line != NULL) | |
23 { | |
24 th_free(line->buf); | |
25 th_free(line); | |
26 } | |
27 } | |
28 | |
29 | |
19 static nn_window_t *nn_window_new(const char *id) | 30 static nn_window_t *nn_window_new(const char *id) |
20 { | 31 { |
21 nn_window_t *res = th_calloc(1, sizeof(nn_window_t)); | 32 nn_window_t *res = th_calloc(1, sizeof(nn_window_t)); |
22 | 33 |
23 if (res == NULL) return NULL; | 34 if (res == NULL) return NULL; |
24 | 35 |
25 res->data = th_ringbuf_new(NN_BACKBUF_LEN, th_free); | 36 res->data = th_ringbuf_new(NN_BACKBUF_LEN, nn_line_free); |
26 if (res->data == NULL) | 37 if (res->data == NULL) |
27 { | 38 { |
28 th_free(res); | 39 th_free(res); |
29 return NULL; | 40 return NULL; |
30 } | 41 } |