Skip to content

use non-throwing new operator to allocate memory for sfObj_create / sfObj_copy #336

Open
@ZXShady

Description

@ZXShady
sfSound* sfSound_create(const sfSoundBuffer* buffer)
{
    assert(buffer);
    return new 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions