replace per header mallocs with single malloc 3 level struct

This big patch replaces the malloc / realloc per header
approach used until now with a single three-level struct
that gets malloc'd during the header union phase and freed
in one go when we transition to a different union phase.

It's more expensive in that we malloc a bit more than 4Kbytes,
but it's a lot cheaper in terms of malloc, frees, heap fragmentation,
no reallocs, nothing to configure.  It also moves from arrays of
pointers (8 bytes on x86_64) to unsigned short offsets into the
data array, (2 bytes on all platforms).

The 3-level thing is all in one struct

 - array indexed by the header enum, pointing to first "fragment" index
	(ie, header type to fragment lookup, or 0 for none)

 - array of fragments indexes, enough for 2 x the number of known headers
	(fragment array... note that fragments can point to a "next"
	fragment if the same header is spread across multiple entries)

 - linear char array where the known header payload gets written
	(fragments point into null-terminated strings stored in here,
	only the known header content is stored)

http headers can legally be split over multiple headers of the same
name which should be concatenated.  This scheme does not linearly
conatenate them but uses a linked list in the fragment structs to
link them.  There are apis to get the total length and copy out a
linear, concatenated version to a buffer.

Signed-off-by: Andy Green <andy.green@linaro.org>
diff --git a/lib/client-handshake.c b/lib/client-handshake.c
index 75e0b41..01aae4d 100644
--- a/lib/client-handshake.c
+++ b/lib/client-handshake.c
@@ -253,10 +253,8 @@
 	if (!wsi->c_callback)
 		wsi->c_callback = context->protocols[0].callback;
 
-	for (n = 0; n < WSI_TOKEN_COUNT; n++) {
-		wsi->u.hdr.hdrs[n].token = NULL;
-		wsi->u.hdr.hdrs[n].token_len = 0;
-	}
+	if (lws_allocate_header_table(wsi))
+		goto oom3;
 
 #ifndef LWS_NO_EXTENSIONS
 	/*