girepository: Return pointer array for interface cache

In g_irepository_get_object_gtype_interfaces(), returning the address of
the first GIBaseInfo* does not work reliably, because the GIBaseInfos
are not necessarily stored contiguously. So the second and subsequent
ones might be garbage.

Instead, return the address of the array of GIBaseInfo pointers.

Add a test that verifies the functionality, as well.

This is unfortunately an API and ABI break.
This commit is contained in:
Philip Chimento 2019-06-20 00:18:13 -07:00
parent 1a19f05a0e
commit a458c66cbf
2 changed files with 4 additions and 4 deletions

View File

@ -984,13 +984,13 @@ g_irepository_find_by_error_domain (GIRepository *repository,
* returning a concrete class of #GLocalFile, which is a #GType we
* see at runtime, but not statically.
*
* Since: 1.60
* Since: 1.62
*/
void
g_irepository_get_object_gtype_interfaces (GIRepository *repository,
GType gtype,
guint *n_interfaces_out,
GIInterfaceInfo **interfaces_out)
GIInterfaceInfo ***interfaces_out)
{
GTypeInterfaceCache *cache;
@ -1039,7 +1039,7 @@ g_irepository_get_object_gtype_interfaces (GIRepository *repository,
}
*n_interfaces_out = cache->n_interfaces;
*interfaces_out = *((GIInterfaceInfo**)&(cache->interfaces[0]));
*interfaces_out = (GIInterfaceInfo**)&cache->interfaces[0];
}
static void

View File

@ -163,7 +163,7 @@ GI_AVAILABLE_IN_1_60
void g_irepository_get_object_gtype_interfaces (GIRepository *repository,
GType gtype,
guint *n_interfaces_out,
GIInterfaceInfo **interfaces_out);
GIInterfaceInfo ***interfaces_out);
GI_AVAILABLE_IN_ALL
gint g_irepository_get_n_infos (GIRepository *repository,