Add support for custom memory allocator to BasicWriter