gistructinfo: Use proper types for offset lookup

This is a private function so we can just use the expected types.

Also this avoids a signed/unsigned conversion.
This commit is contained in:
Marco Trevisan (Treviño) 2024-01-16 01:41:43 +01:00
parent 19476db825
commit 13791b47f6

View File

@ -72,16 +72,16 @@ gi_struct_info_get_n_fields (GIStructInfo *info)
* Returns: field offset, in bytes * Returns: field offset, in bytes
* Since: 2.80 * Since: 2.80
*/ */
static int32_t static size_t
gi_struct_get_field_offset (GIStructInfo *info, gi_struct_get_field_offset (GIStructInfo *info,
unsigned int n) uint16_t n)
{ {
GIRealInfo *rinfo = (GIRealInfo *)info; GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data; Header *header = (Header *)rinfo->typelib->data;
uint32_t offset = rinfo->offset + header->struct_blob_size; size_t offset = rinfo->offset + header->struct_blob_size;
FieldBlob *field_blob; FieldBlob *field_blob;
for (unsigned int i = 0; i < n; i++) for (uint16_t i = 0; i < n; i++)
{ {
field_blob = (FieldBlob *)&rinfo->typelib->data[offset]; field_blob = (FieldBlob *)&rinfo->typelib->data[offset];
offset += header->field_blob_size; offset += header->field_blob_size;