Mercurial > hg > nnchat
diff libnnchat.c @ 325:c086345d176b
Move some functions to libnnchat and rename nn_find_window to findWindow()
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 11 Jun 2011 10:03:44 +0300 |
parents | a0c001672b44 |
children | 8e509d6546d3 |
line wrap: on
line diff
--- a/libnnchat.c Sat Jun 11 09:49:42 2011 +0300 +++ b/libnnchat.c Sat Jun 11 10:03:44 2011 +0300 @@ -891,3 +891,29 @@ } +nn_window_t *nn_window_new(const char *id) +{ + nn_window_t *res = th_calloc(1, sizeof(nn_window_t)); + + if (res == NULL) return NULL; + + res->data = th_ringbuf_new(NN_BACKBUF_LEN, th_free); + if (res->data == NULL) { + th_free(res); + return NULL; + } + + res->id = th_strdup(id); + + return res; +} + + +void nn_window_free(nn_window_t *win) +{ + if (win != NULL) { + th_ringbuf_free(win->data); + th_free(win->id); + th_free(win); + } +}