Instead of replacing the global new operator we could write a custom allocator that uses xmalloc, and we can have e.g. gcc::string as a typedef for std::basic_string<char, std::char_traits<char>, gcc::xmallocator<char>>