GNOME Bugzilla – Bug 660743
macro wrappers for g_once_init_enter/leave
Last modified: 2011-10-04 15:01:51 UTC
g_once_init_enter/leave() is a totally awesome API with one wart: it takes gsize* when you almost always want to deal in pointers. We have some macro magic that makes g_atomic_pointer_*() work with any pointer-sized value. We should add the same for g_once_init.
Created attachment 198138 [details] [review] macro wrappers for g_once_init_enter/leave Give the macro wrapper treatment to g_once_init_enter() and leave() in the same style that we did for gatomic. It is now possible to use these macros with any pointer-sized object, and not just gsize. The leave() macro ensures that the initialisation result is a compatible type with the pointer that it is being written to. Just like with gatomic, there could be problems caused by use of (void*) casts. We'll see how that goes, and reevaluate if necessary.
Review of attachment 198138 [details] [review]: ok
Should add a warning to the README though, about possible problems with explicit casts.
Attachment 198138 [details] pushed as 794c1a3 - macro wrappers for g_once_init_enter/leave
Added a couple of README notes in a separate commit.