Wow, why is this not in GLib? :-)
In any case, I'd rather leave the `g_` prefix alone and rename this function.