revised maiallocator.cpp