So I was testing the threaded code on FreeBSD, and discovered I'd forgotten to check to see if the malloc.c that shipped with bro was thread-safe. Oops.
When I went to browse malloc.c's source, I found out that it was dlmalloc. Further, it appears that dlmalloc is not really meant to support threads . With that in mind, I'm wondering if malloc.c is really necessary; most systems these days have a pretty good default allocator (, ). From what I've read, jemalloc in particular (default allocator in FreeBSD 7+) is competitive with the Linux default allocator (ptmalloc2 derivative) , and is used in one context or another by Firefox and Facebook to help with memory fragmentation issues .
For folks worried about performance, there's always tcmalloc ; this comes with google perftools, but would it be a good idea to just embed this in the project?
With the above in mind, what would y'all think about either:
*) Removing malloc.c entirely
*) Replacing dlmalloc with e.g. ptmalloc3 (which I believe to be licensed under something BSD-like, but need to check on that) or jemalloc (BSD-ish license )
 From dlmalloc's source: "... When USE_LOCKS is defined, each public call to malloc, free, etc is surrounded with either a pthread mutex or a win32 spinlock (depending on WIN32). This is not especially fast, and can be a major bottleneck..."