[A5] does al_destroy_user_event_source free the event source memory?

Does the function al_destroy_user_event_source free the memory occupied by the event source? the manual doesn't say if it does. I assume that it does not, given that the corresponding init function does not allocate memory for the event source.

I think the word 'destroy' is misleading in this case; perhaps it should be changed to 'cleanup', assuming that the function does not free the memory occupied by the event source. Usually, functions are named 'create' and 'destroy' if they allocate and free memory correspondingly, or 'init' and 'cleanup' if they don't manage memory.

The above, of course, is valid if my assumption about the function not freeing the event source memory.


It works as you assumed. Feel free to submit a patch to make the documentation clearer - maybe the destruction part for the example in al_init_user_event_source could be added as example to al_destroy_user_event_source. The free() call in there should remove any doubt as to who is responsible for freeing the memory.

About the naming I completely agree, destroy always means to free the memory, in the rest of the API. Too bad it can't be changed for 5.0 any longer, but hopefully for 5.2 (although I'm somewhat afraid we'll adopt a policy of trying to break as little 5.0 code as possible instead :/).

Peter Wang

Added a sentence. To be fair, if you allocated the memory, Allegro can't free it. Ok, if we were amateurs we might have made that mistake, but we're not, are we? ;)

We can rename it in 5.2 with a backwards compatibility #define if it's that important.

Thread #606663. Printed from Allegro.cc