mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
Fix type of length returned by gvdb_table_get_names()
It should not be unsigned. The type in the on-disk format is gint32, so we need to return something at least as wide as that. However, we should not expose the implementation detail that the on-disk format is specifically gint32. Use a gsize, since that’s the normal type for array lengths — but check that we’re not on a platform where (somehow) gsize is smaller than gint32. Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
parent
7bed7ea77d
commit
a44329c244
@ -348,7 +348,7 @@ gvdb_table_list_from_item (GvdbTable *table,
|
||||
**/
|
||||
gchar **
|
||||
gvdb_table_get_names (GvdbTable *table,
|
||||
gint *length)
|
||||
gsize *length)
|
||||
{
|
||||
gchar **names;
|
||||
gint n_names;
|
||||
@ -474,7 +474,10 @@ gvdb_table_get_names (GvdbTable *table,
|
||||
}
|
||||
|
||||
if (length)
|
||||
*length = n_names;
|
||||
{
|
||||
G_STATIC_ASSERT (sizeof (*length) >= sizeof (n_names));
|
||||
*length = n_names;
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ G_GNUC_INTERNAL
|
||||
void gvdb_table_free (GvdbTable *table);
|
||||
G_GNUC_INTERNAL
|
||||
gchar ** gvdb_table_get_names (GvdbTable *table,
|
||||
gint *length);
|
||||
gsize *length);
|
||||
G_GNUC_INTERNAL
|
||||
gchar ** gvdb_table_list (GvdbTable *table,
|
||||
const gchar *key);
|
||||
|
Loading…
Reference in New Issue
Block a user