changeset 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 1807059fb8f2
children 2d8967497e21
files libnnchat.c libnnchat.h
diffstat 2 files changed, 0 insertions(+), 49 deletions(-) [+]
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;
--- 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);