You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sfSound* sfSound_create(const sfSoundBuffer* buffer)
{
assert(buffer);
returnnew sfSound{sf::Sound(buffer->This), buffer};
// what would happen if new throws?
}
best to replace it with new(std::nothrow) which returns null on allocation failure. the copy can still fail and throw an exception!
C doesn't have exceptions and in general we should catch exceptions and translate them to error codes or let nothrow new do that for us.
The text was updated successfully, but these errors were encountered:
ZXShady
changed the title
use non-throwing new operator to allocate memory for sfObj_create sfObj_copy
use non-throwing new operator to allocate memory for sfObj_create / sfObj_copy
Sep 17, 2024
best to replace it with
new(std::nothrow)
which returns null on allocation failure. the copy can still fail and throw an exception!C doesn't have exceptions and in general we should catch exceptions and translate them to error codes or let nothrow new do that for us.
The text was updated successfully, but these errors were encountered: