Hi Mike,
The issue here is that the call to new will throw a bad_alloc exception, which will take you to __lib_prog_term if it hasn't been caught.
So what you'd need to do in this case is either wrap the call to new in a try/catch handler:
void *newBaseAddress;
try {
newBaseAddress = new (1) COFFEEPOT_STRUCTURE;
} catch (std::bad_alloc ba) {
newBaseAddress = 0;
}
or call the nothrow version, which will return 0:
void *newBaseAddress = new (std::nothrow,1) COFFEEPOT_STRUCTURE;