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 - SDL_Error() should unconditionally return -1?
Summary: SDL_Error() should unconditionally return -1?
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.0
Hardware: All All
: P2 minor
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-30 22:51 UTC by Ryan C. Gordon
Modified: 2013-03-31 19:08 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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! :)