# HG changeset patch # User Matti Hamalainen # Date 1307608773 -10800 # Node ID 2cff949abbc535d9a745e352c7cb95b71f368307 # Parent 1807059fb8f29b793126f13c8b2abadafddd0dc6 Remove ringbuf implementation, it's been moved to th-libs. diff -r 1807059fb8f2 -r 2cff949abbc5 libnnchat.c --- 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; diff -r 1807059fb8f2 -r 2cff949abbc5 libnnchat.h --- a/libnnchat.h Thu Jun 09 11:37:34 2011 +0300 +++ b/libnnchat.h Thu Jun 09 11:39:33 2011 +0300 @@ -32,12 +32,6 @@ #define NN_DELAY_USEC (15 * 1000) typedef struct { - char **data; - size_t n, size; -} nn_ringbuf_t; - - -typedef struct { ssize_t pos, len, size; char *data; } nn_editbuf_t; @@ -50,7 +44,6 @@ } nn_user_t; - typedef struct { nn_user_t *buckets[NN_NUM_BUCKETS]; } nn_userhash_t; @@ -112,11 +105,6 @@ char * nn_dblencode_str(const char *str); -nn_ringbuf_t * nn_ringbuf_new(const size_t size); -void nn_ringbuf_free(nn_ringbuf_t *buf); -void nn_ringbuf_add(nn_ringbuf_t *buf, const char *str); - - int nn_editbuf_write(nn_editbuf_t *buf, ssize_t pos, int ch); int nn_editbuf_insert(nn_editbuf_t *buf, ssize_t pos, int ch); int nn_editbuf_delete(nn_editbuf_t *buf, ssize_t pos);