Mercurial > hg > nnchat
diff libnnchat.c @ 277:2cff949abbc5
Remove ringbuf implementation, it's been moved to th-libs.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 09 Jun 2011 11:39:33 +0300 |
parents | 1211b740fbda |
children | b765f15f9895 |
line wrap: on
line diff
--- a/libnnchat.c Thu Jun 09 11:37:34 2011 +0300 +++ b/libnnchat.c Thu Jun 09 11:39:33 2011 +0300 @@ -539,43 +539,6 @@ } -nn_ringbuf_t * nn_ringbuf_new(const size_t size) -{ - nn_ringbuf_t *res = th_calloc(1, sizeof(nn_ringbuf_t)); - - res->data = (char **) th_malloc(size * sizeof(char *)); - res->size = size; - res->n = 0; - - return res; -} - - -void nn_ringbuf_free(nn_ringbuf_t *buf) -{ - size_t i; - - for (i = 0; i < buf->n; i++) - th_free(buf->data[i]); - - th_free(buf->data); - th_free(buf); -} - - -void nn_ringbuf_add(nn_ringbuf_t *buf, const char *str) -{ - if (buf->n < buf->size) { - buf->data[buf->n] = th_strdup(str); - buf->n++; - } else { - th_free(buf->data[0]); - memmove(&(buf->data[0]), &(buf->data[1]), buf->size - 1); - buf->data[buf->size - 1] = th_strdup(str); - } -} - - int nn_editbuf_write(nn_editbuf_t *buf, ssize_t pos, int ch) { if (buf->len+1 >= buf->size) return -3;