1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-23 00:00:06 +01:00
libwebsockets/test-server
Andy Green 16ab3185c4 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>
2013-02-11 11:10:57 +08:00
..
.gitignore Ignoring linux build files 2013-01-09 15:46:11 +08:00
favicon.ico refactor-into-dirs.patch 2010-11-01 09:12:17 +00:00
libwebsockets.org-logo.png add libwebsockets.org logo to share 2013-01-16 10:00:39 +08:00
Makefile.am introduce test echo 2013-01-30 12:28:44 +08:00
test-client.c correct test client to close synchronously with last send 2013-02-09 14:27:24 +08:00
test-echo.c change context creation params to struct 2013-02-09 14:01:09 +08:00
test-fraggle.c change context creation params to struct 2013-02-09 14:01:09 +08:00
test-ping.c change context creation params to struct 2013-02-09 14:01:09 +08:00
test-server.c replace per header mallocs with single malloc 3 level struct 2013-02-11 11:10:57 +08:00
test.html renovate test html 2013-01-31 19:50:57 +08:00