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 1448

Summary: SDL_PushEvent does not copy event
Product: SDL Reporter: andre
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED INVALID QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: john
Version: HG 2.0   
Hardware: x86_64   
OS: Linux   

Description andre 2012-03-13 15:35:40 UTC
The docs for SDL_PushEvent state "The event is copied into the queue, and the caller may dispose of the memory pointed to after SDL_PushEvent() returns.".  This is not the case in the current HG codebase.  I am not sure if this is a documentation error, a non-implemented feature, or a bug.  The pointer for the event is copied, and the event itself is not copied.
Comment 1 john 2013-02-18 14:37:59 UTC
The event is copied by value. SDL_PushEvent calls SDL_PeepEvent, which calls SDL_AddEvent, which performs the by-value copy.
Comment 2 Sam Lantinga 2013-03-01 01:25:52 UTC
Note that if your event contains userdata pointers, the pointers are copied, not the memory they point to.  You need to manage those objects yourself and make sure you don't free them while the event is being delivered.