mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-23 18:52:09 +01:00
giunioninfo: Mark get_discriminator_type() as nullable
It may (and should) return `NULL` if called on a union which isn’t discriminated. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Helps: #3155
This commit is contained in:
parent
11e8075e51
commit
e286497c1f
@ -183,7 +183,8 @@ gi_union_info_get_discriminator_offset (GIUnionInfo *info,
|
||||
*
|
||||
* Obtain the type information of the union discriminator.
|
||||
*
|
||||
* Returns: (transfer full): the [type@GIRepository.TypeInfo], free it with
|
||||
* Returns: (transfer full) (nullable): the [type@GIRepository.TypeInfo], or
|
||||
* `NULL` if the union is not discriminated. Free it with
|
||||
* [method@GIRepository.BaseInfo.unref] when done.
|
||||
* Since: 2.80
|
||||
*/
|
||||
@ -191,6 +192,10 @@ GITypeInfo *
|
||||
gi_union_info_get_discriminator_type (GIUnionInfo *info)
|
||||
{
|
||||
GIRealInfo *rinfo = (GIRealInfo *)info;
|
||||
UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset];
|
||||
|
||||
if (!blob->discriminated)
|
||||
return NULL;
|
||||
|
||||
return gi_type_info_new ((GIBaseInfo*)info, rinfo->typelib, rinfo->offset + 24);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user