improvement suggestions in HTMemory.c

Hi,

I have an improvement suggestion for HTMemory.c.
As we know, libwww is not thread safe. However, when integrating the latest
patches it is very reliable when using the async mode, which is equally
powerful compared to multithreading. In some cases, it also might have some
advantages.
Having this in mind, an implementation might want to run libwww in a
separate thread, waiting for some results and fork a thread to process the
data libwww received from a web server. The HTChunk() data structure are
very convenient for doing so as it forms the basis for request outputs. 
Unfortunatly, HTChunk() is not thread safe simply because HTMemory.c is not.
For example, check out this code in HTmemory:

PUBLIC void * HTMemory_calloc (size_t nobj, size_t size)
{
    void * ptr;
    ptr = calloc(nobj, LastAllocSize = size);
...

here, the input into a function is taken from the output of an assignment to
a global static valiable. This is not thread safe because a different thread
may change the valiable in between the call, leading to wrong input
parameters. Because of that I suggest to change the code to 

PUBLIC void * HTMemory_calloc (size_t nobj, size_t size)
{
    void * ptr;
    LastAllocSize = size
    ptr = calloc(nobj, size);
...

I have attached a diff file that does includes all other changes.

Jens



 <<diff.txt>> 

Received on Sunday, 25 March 2001 17:41:29 UTC