[MEDIUM] http: don't use trash to realign large buffers

The trash buffer may now be smaller than a buffer because we can tune
it at run time. This causes a risk when we're trying to use it as a
temporary buffer to realign unaligned requests, because we may have to
put up to a full buffer into it.

Instead of doing a double copy, we're now relying on an open-coded
bouncing copy algorithm. The principle is that we move one byte at
a time to its final place, and if that place also holds a byte, then
we move it too, and so on. We finish when we've moved all the buffer.
It limits the number of memory accesses, but since it proceeds one
byte at a time and with random walk, it's not cache friendly and
should be slower than a double copy. However, it's only used in
extreme situations and the difference will not be noticeable.

It has been extensively tested and works reliably.
diff --git a/include/proto/buffers.h b/include/proto/buffers.h
index e046f39..f174b87 100644
--- a/include/proto/buffers.h
+++ b/include/proto/buffers.h
@@ -2,7 +2,7 @@
  * include/proto/buffers.h
  * Buffer management definitions, macros and inline functions.
  *
- * Copyright (C) 2000-2009 Willy Tarreau - w@1wt.eu
+ * Copyright (C) 2000-2010 Willy Tarreau - w@1wt.eu
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -429,6 +429,8 @@
 int buffer_replace2(struct buffer *b, char *pos, char *end, const char *str, int len);
 int buffer_insert_line2(struct buffer *b, char *pos, const char *str, int len);
 void buffer_dump(FILE *o, struct buffer *b, int from, int to);
+void buffer_bounce_realign(struct buffer *buf);
+
 
 
 /* writes the chunk <chunk> to buffer <buf>. Returns -1 in case of success,