GVariant: clean up serialised data handling API
Add a new pair of internal helpers to gvariant-core.c to provide a
unified way to construct and query the content of serialised GVariant
instances.
Rewrite g_variant_new_from_data() to use this.
Move g_variant_new_from_bytes() and g_variant_get_data_as_bytes() out of
-core and into gvariant.c, also rewriting them to use the same.
Take the time to do some cleanup and make some general improvements in
consistency:
- move the checks for improperly sized fixed-sized data out of
_new_from_bytes() and into the common code so that we do this check
on _new_from_data() as well
- correctly deal with the case of NULL data in _get_data_as_bytes().
This would have crashed before. Add a test for that.
- if the user hands us data with a size of zero then unref and/or
destroy-notify things immediately.
The idea that every GVariant must have an associated GBytes remains.
This could potentially be optimsed a bit further in the future, but the
cases where it could be avoided are only a few (errors, zero-size,
static stoarge) so let's not pursue that now.