Hi folks- *tl;dr **plarena.h has been replaced, stop using it.*
In bug 943156 [0] I recently landed [1] a templatized arena allocator, mozilla::ArenaAllocator, that we can used as a drop-in replacement for PLArenaPool. This has the benefit of getting rid of the odd "#define this thing before including plarena.h" paradigm that is spread throughout the code base, additionally we can build files that use ArenaAllocator in unified mode. Initial micro-benchmarking indicates that the performance of ArenaAllocator is as good or better than PLArenaPool. At this point we shouldn't need to use plarena.h. I've gone ahead and converted all existing usage of PLArenaPool over to ArenaAllocator [2, 3, 4, 5]. *Further details:* The usage is pretty straightforward. Here's an example of defining an allocator what uses a 4K arena size and 8-byte alignment to allocate 10 bytes: #include "mozilla/ArenaAllocator.h" mozilla::ArenaAllocator<4096, 8> a; // By default allocation is infallible: void* x = a.Allocate(10); // kaboom on OOM // But you can also allocate fallibly: void* y = a.Allocate(10, mozilla::fallible); if (!y) return NS_ERROR_OUT_OF_MEMORY; Additionally if you find yourself using an arena to manage strings, you may find the arena allocator extensions [6] helpful: #include "mozilla/ArenaAllocatorExtensions.h" char* fromCStr = mozilla::ArenaStrdup("a string", a); There are versions for nsAString and nsACString as well. -e [0] https://bugzilla.mozilla.org/show_bug.cgi?id=943156 [1] https://hg.mozilla.org/mozilla-central/rev/f09969186032 [2] https://bugzilla.mozilla.org/show_bug.cgi?id=1351732 [3] https://bugzilla.mozilla.org/show_bug.cgi?id=1351801 [4] https://bugzilla.mozilla.org/show_bug.cgi?id=1351804 [5] https://bugzilla.mozilla.org/show_bug.cgi?id=1351904 [6] https://hg.mozilla.org/mozilla-central/file/tip/xpcom/ds/ArenaAllocatorExtensions.h _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform