RFC: new conventions for _clear() functions
Submitted by Allison (desrt)
Link to original bug (#743971)
Description
I propose that we establish a convention that says that all _clear functions are idempotent.
Main argument: this is already the case for some _clear() functions: notably those on GVariantBuilder, GVariantDict, GQueue, etc. For other types it's undefined. We have an inconsistency. We can't change the functions that are already defined to work, so if we want consistency, we need to change the undefined ones.
Open question is if we guarantee _clear() to also work (and do nothing) on zero-filled memory. Often _clear() will function by resetting the memory in question to all-zeros so we will sometimes get this for free anyway, but it's not always the case. Consistency would again suggest that we do this everywhere.
In addition to being an improvement in consistency it will also make _clear() functions nicer for use with g_auto(). As it stands, if you set up a g_auto() variable for a stack-allocated type with a _clear() function then you can get yourself into some pretty annoying situations.