[Libwebsockets] lwsac

Andy Green andy at warmcat.com
Mon Oct 15 23:46:38 CEST 2018

Hi -

There's quite a lot of work coming back from gitohashi into lws... 
originally gitohashi was split into a separate headless library that 
could operate without linking to lws.  That "libjsongit2" library 
migrated to be a library iniside gitohashi a while ago, and since 
gitohashi itself relies on lws, lws became available to the bits in the 
library as a dependency.  Conversely, stuff in the library is then 
available to migrate to lws instead if it also has uses outside of 

Lwsac is a way to allocate for an unknown but potentially large number 
of small allocations efficiently.  Basically it allocates a linked-list 
of chunks and then sub-allocates inside them without any attempt to 
track the individual allocations except the high-water mark in the chunk.

It replaces individual per-string or per-struct mallocs, and has the 
advantage when you're finished with it, you simply call an api to free 
the chunks, not the sub-allocations.


There's an example how to use here, it is very simple.


This may seem a bit trivial but aside from being useful in its own 
right, it's central to a larger feature coming next.


More information about the Libwebsockets mailing list