MINOR: chunks: centralize the trash chunk allocation

At the moment, we need trash chunks almost everywhere and the only
correctly implemented one is in the sample code. Let's move this to
the chunks so that all other places can use this allocator.

Additionally, the get_trash_chunk() function now really returns two
different chunks. Previously it used to always overwrite the same
chunk and point it to a different buffer, which was a bit tricky
because it's not obvious that two consecutive results do alias each
other.
diff --git a/src/sample.c b/src/sample.c
index 3c0d01e..b3898e0 100644
--- a/src/sample.c
+++ b/src/sample.c
@@ -26,13 +26,6 @@
 /* static sample used in sample_process() when <p> is NULL */
 static struct sample temp_smp;
 
-/* trash chunk used for sample conversions */
-static struct chunk trash_chunk;
-
-/* trash buffers used or sample conversions */
-char *sample_trash_buf1;
-char *sample_trash_buf2;
-
 /* list head of all known sample fetch keywords */
 static struct sample_fetch_kw_list sample_fetches = {
 	.list = LIST_HEAD_INIT(sample_fetches.list)
@@ -101,24 +94,6 @@
 	return NULL;
 }
 
-
-/*
-* Returns a static trash struct chunk to use in sample casts or format conversions
-* Swiths the 2 available trash buffers to protect data during convert
-*/
-struct chunk *sample_get_trash_chunk(void)
-{
-	char *sample_trash_buf;
-
-	sample_trash_buf  = sample_trash_buf1;
-	sample_trash_buf1 = sample_trash_buf2;
-	sample_trash_buf2 = sample_trash_buf1;
-
-	chunk_init(&trash_chunk, sample_trash_buf, global.tune.bufsize);
-
-	return &trash_chunk;
-}
-
 /******************************************************************/
 /*          Sample casts functions                                */
 /*   Note: these functions do *NOT* set the output type on the    */
@@ -133,7 +108,7 @@
 
 static int c_ip2str(struct sample *smp)
 {
-	struct chunk *trash = sample_get_trash_chunk();
+	struct chunk *trash = get_trash_chunk();
 
 	if (!inet_ntop(AF_INET, (void *)&smp->data.ipv4, trash->str, trash->size))
 		return 0;
@@ -152,7 +127,7 @@
 
 static int c_ipv62str(struct sample *smp)
 {
-	struct chunk *trash = sample_get_trash_chunk();
+	struct chunk *trash = get_trash_chunk();
 
 	if (!inet_ntop(AF_INET6, (void *)&smp->data.ipv6, trash->str, trash->size))
 		return 0;
@@ -189,7 +164,7 @@
 
 static int c_bin2str(struct sample *smp)
 {
-	struct chunk *trash = sample_get_trash_chunk();
+	struct chunk *trash = get_trash_chunk();
 	unsigned char c;
 	int ptr = 0;
 
@@ -205,7 +180,7 @@
 
 static int c_int2str(struct sample *smp)
 {
-	struct chunk *trash = sample_get_trash_chunk();
+	struct chunk *trash = get_trash_chunk();
 	char *pos;
 
 	pos = ultoa_r(smp->data.uint, trash->str, trash->size);
@@ -222,7 +197,7 @@
 
 static int c_datadup(struct sample *smp)
 {
-	struct chunk *trash = sample_get_trash_chunk();
+	struct chunk *trash = get_trash_chunk();
 
 	trash->len = smp->data.str.len < trash->size ? smp->data.str.len : trash->size;
 	memcpy(trash->str, smp->data.str.str, trash->len);