Added buffer so we can buffer entire lines in a later patch.
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Wed, 10 Jun 2009 23:01:05 +0000 (20:01 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Wed, 10 Jun 2009 23:01:05 +0000 (20:01 -0300)
pop.c

diff --git a/pop.c b/pop.c
index f286056..8de50f4 100644 (file)
--- a/pop.c
+++ b/pop.c
@@ -20,6 +20,7 @@
 
 #include <gnet.h>
 #include <glib.h>
+#include <string.h>
 #include "nethook.h"
 #include "pop.h"
 
@@ -27,6 +28,7 @@ typedef struct
 {
   net_read orig_read;
   gpointer orig_data;
+  GString *buffer;
 } pop_t;
 
 static void
@@ -45,6 +47,7 @@ pop_hook_new (net_hook_t *layer)
   pop = g_slice_new (pop_t);
   pop->orig_read = layer->read;
   pop->orig_data = layer->data;
+  pop->buffer = g_string_sized_new (4096);
   layer->read = pop_read;
   layer->data = pop;
   return layer;
@@ -53,5 +56,9 @@ pop_hook_new (net_hook_t *layer)
 void
 pop_destroy (net_hook_t *hook)
 {
-  g_slice_free (net_hook_t, hook->data);
+  pop_t *pop = hook->data;
+  g_string_free (pop->buffer, TRUE);
+  hook->read = pop->orig_read;
+  hook->data = pop->orig_data;
+  g_slice_free (net_hook_t, (gpointer) pop);
 }