[MAJOR] switched buffers to mempools v2
diff --git a/include/proto/buffers.h b/include/proto/buffers.h
index 6c39962..74efe8f 100644
--- a/include/proto/buffers.h
+++ b/include/proto/buffers.h
@@ -22,11 +22,19 @@
 #ifndef _PROTO_BUFFERS_H
 #define _PROTO_BUFFERS_H
 
+#include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <common/config.h>
+#include <common/memory.h>
 #include <types/buffers.h>
 
+extern struct pool_head *pool2_buffer;
+
+/* perform minimal intializations, report 0 in case of error, 1 if OK. */
+int init_buffer();
+
 /* Initializes all fields in the buffer. The ->rlim field is initialized last
  * so that the compiler can optimize it away if changed immediately after the
  * call to this function.
diff --git a/include/types/buffers.h b/include/types/buffers.h
index 9b781b8..09d1e34 100644
--- a/include/types/buffers.h
+++ b/include/types/buffers.h
@@ -73,9 +73,6 @@
 	char data[BUFSIZE];
 };
 
-#define sizeof_buffer   sizeof(struct buffer)
-extern void **pool_buffer;
-
 
 #endif /* _TYPES_BUFFERS_H */
 
diff --git a/src/buffers.c b/src/buffers.c
index 5739fcf..658539c 100644
--- a/src/buffers.c
+++ b/src/buffers.c
@@ -15,9 +15,19 @@
 #include <string.h>
 
 #include <common/config.h>
+#include <common/memory.h>
 #include <proto/buffers.h>
 
-void **pool_buffer   = NULL;
+struct pool_head *pool2_buffer;
+
+
+/* perform minimal intializations, report 0 in case of error, 1 if OK. */
+int init_buffer()
+{
+	pool2_buffer = create_pool("buffer", sizeof(struct buffer), MEM_F_SHARED);
+	return pool2_buffer != NULL;
+}
+
 
 /* writes <len> bytes from message <msg> to buffer <buf>. Returns 0 in case of
  * success, or the number of bytes available otherwise.
diff --git a/src/client.c b/src/client.c
index 6afb206..6a1a3df 100644
--- a/src/client.c
+++ b/src/client.c
@@ -347,7 +347,7 @@
 			write(1, trash, len);
 		}
 
-		if ((s->req = pool_alloc(buffer)) == NULL) { /* no memory */
+		if ((s->req = pool_alloc2(pool2_buffer)) == NULL) { /* no memory */
 			if (txn->hdr_idx.v != NULL)
 				pool_free_to(p->hdr_idx_pool, txn->hdr_idx.v);
 			if (txn->rsp.cap != NULL)
@@ -369,8 +369,8 @@
 		s->req->wto = s->be->srvtimeout;
 		s->req->cto = s->be->srvtimeout;
 
-		if ((s->rep = pool_alloc(buffer)) == NULL) { /* no memory */
-			pool_free(buffer, s->req);
+		if ((s->rep = pool_alloc2(pool2_buffer)) == NULL) { /* no memory */
+			pool_free2(pool2_buffer, s->req);
 			if (txn->hdr_idx.v != NULL)
 				pool_free_to(p->hdr_idx_pool, txn->hdr_idx.v);
 			if (txn->rsp.cap != NULL)
diff --git a/src/haproxy.c b/src/haproxy.c
index 18bef85..59c6149 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -374,6 +374,7 @@
 	localtime((time_t *)&now.tv_sec);
 	start_date = now;
 
+	init_buffer();
 	init_task();
 	init_session();
 	init_proto_http();
@@ -661,7 +662,7 @@
 	if (fdtab)            free(fdtab);
     
 	pool_destroy2(pool2_session);
-	pool_destroy(pool_buffer);
+	pool_destroy2(pool2_buffer);
 	pool_destroy(pool_requri);
 	pool_destroy2(pool2_task);
 	pool_destroy(pool_capture);
diff --git a/src/session.c b/src/session.c
index 63bede3..1b574a0 100644
--- a/src/session.c
+++ b/src/session.c
@@ -21,6 +21,7 @@
 #include <types/proxy.h>
 #include <types/server.h>
 
+#include <proto/buffers.h>
 #include <proto/hdr_idx.h>
 #include <proto/session.h>
 #include <proto/queue.h>
@@ -38,9 +39,9 @@
 	if (s->pend_pos)
 		pendconn_free(s->pend_pos);
 	if (s->req)
-		pool_free(buffer, s->req);
+		pool_free2(pool2_buffer, s->req);
 	if (s->rep)
-		pool_free(buffer, s->rep);
+		pool_free2(pool2_buffer, s->rep);
 
 	if (txn->hdr_idx.v != NULL)
 		pool_free_to(s->fe->hdr_idx_pool, txn->hdr_idx.v);