We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1778

Summary: SDL_Error() should unconditionally return -1?
Product: SDL Reporter: Ryan C. Gordon <icculus>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: minor    
Priority: P2    
Version: HG 2.0   
Hardware: All   
OS: All   

Description Ryan C. Gordon 2013-03-30 22:51:41 UTC
This might be a stupid idea, but I'll throw it out there.

SDL_Error() should return an int, and always return -1.

It makes this code...

    if (malloc(16) == NULL)
    {
        SDL_OutOfMemory();   // this is a macro of SDL_Error().
        return -1;  // what most SDL entry points return for errors.
    }


...into the more-compact form:

    if (malloc(16) == NULL)
        return SDL_OutOfMemory();


We can change this without breaking the 2.0 ABI, as any existing code expects this to return void and thus won't care if it suddenly returns a value.

--ryan.
Comment 1 Ryan C. Gordon 2013-03-30 22:52:17 UTC
Tossing this to Sam to consider.

--ryan.
Comment 2 Sam Lantinga 2013-03-30 23:46:11 UTC
I like it!
Comment 3 Ryan C. Gordon 2013-03-31 13:06:49 UTC
Fixed in hg changeset 3fedf1f25b94 and 7f22b9ba218f.

This drops 699 lines from the source tree.  :)

--ryan.
Comment 4 Sam Lantinga 2013-03-31 19:08:58 UTC
Woo! :)