Mercurial > hg > nnchat
comparison util.c @ 466:796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 26 May 2012 06:56:18 +0300 |
parents | 35d67bd0613b |
children | 607bd4491e79 |
comparison
equal
deleted
inserted
replaced
465:c3b3b6d89084 | 466:796508f828f6 |
---|---|
681 if (*c == 255) *c = ' '; | 681 if (*c == 255) *c = ' '; |
682 return str; | 682 return str; |
683 } | 683 } |
684 | 684 |
685 | 685 |
686 nn_window_t *nn_window_new(const char *id) | |
687 { | |
688 nn_window_t *res = th_calloc(1, sizeof(nn_window_t)); | |
689 | |
690 if (res == NULL) return NULL; | |
691 | |
692 res->data = th_ringbuf_new(NN_BACKBUF_LEN, th_free); | |
693 if (res->data == NULL) | |
694 { | |
695 th_free(res); | |
696 return NULL; | |
697 } | |
698 | |
699 res->id = th_strdup(id); | |
700 | |
701 return res; | |
702 } | |
703 | |
704 | |
705 void nn_window_free(nn_window_t *win) | |
706 { | |
707 if (win != NULL) | |
708 { | |
709 th_ringbuf_free(win->data); | |
710 th_free(win->id); | |
711 th_free(win); | |
712 } | |
713 } | |
714 | |
715 | |
716 nn_strtuple_t *nn_strtuple_new(size_t len, char *str) | 686 nn_strtuple_t *nn_strtuple_new(size_t len, char *str) |
717 { | 687 { |
718 nn_strtuple_t *tuple = th_calloc(1, sizeof(nn_strtuple_t)); | 688 nn_strtuple_t *tuple = th_calloc(1, sizeof(nn_strtuple_t)); |
719 tuple->len = len; | 689 tuple->len = len; |
720 tuple->str = str; | 690 tuple->str = str; |