girrepository: Replace usage of gsize with standard size_t

We just do a safe s/gsize/size_t/ replacement here without doing any
changes to places in which different size of size_t and gsize may be
actually different and create troubles.
This commit is contained in:
Marco Trevisan (Treviño) 2024-01-16 00:35:23 +01:00
parent c8aecbb834
commit bc2e4b3de5
26 changed files with 60 additions and 61 deletions

View File

@ -44,8 +44,8 @@
static gboolean
write_all (FILE *out,
const void *buffer,
gsize count,
gsize *bytes_written,
size_t count,
size_t *bytes_written,
GError **error)
{
size_t ret;
@ -104,7 +104,7 @@ escaped_printf (FILE *out, const char *fmt, ...)
{
char *str;
va_list args;
gsize written;
size_t written;
GError *error = NULL;
va_start (args, fmt);
@ -123,7 +123,7 @@ escaped_printf (FILE *out, const char *fmt, ...)
static void
goutput_write (FILE *out, const char *str)
{
gsize written;
size_t written;
GError *error = NULL;
if (!write_all (out, str, strlen (str), &written, &error))
{
@ -662,7 +662,7 @@ gi_repository_dump (const char *input_filename,
while (TRUE)
{
gsize len;
size_t len;
char *line = read_line (input, &len);
const char *function;

View File

@ -45,7 +45,7 @@ struct _GIBaseInfoClass
void gi_base_info_init_types (void);
GType gi_base_info_type_register_static (const char *type_name,
gsize instance_size,
size_t instance_size,
GClassInitFunc class_init);
G_END_DECLS

View File

@ -213,7 +213,7 @@ gi_base_info_get_type (void)
*/
GType
gi_base_info_type_register_static (const char *type_name,
gsize instance_size,
size_t instance_size,
GClassInitFunc class_init)
{
GTypeInfo info;
@ -264,7 +264,7 @@ GI_DEFINE_BASE_INFO_TYPE (gi_unresolved_info, GI_INFO_TYPE_UNRESOLVED)
void
gi_base_info_init_types (void)
{
static gsize register_types_once = 0;
static size_t register_types_once = 0;
if (g_once_init_enter (&register_types_once))
{
@ -272,7 +272,7 @@ gi_base_info_init_types (void)
{
GIInfoType info_type;
const char *type_name;
gsize instance_size;
size_t instance_size;
GClassInitFunc class_init;
}
types[] =
@ -297,7 +297,7 @@ gi_base_info_init_types (void)
{ GI_INFO_TYPE_UNRESOLVED, "GIUnresolvedInfo", sizeof (GIUnresolvedInfo), gi_unresolved_info_class_init },
};
for (gsize i = 0; i < G_N_ELEMENTS (types); i++)
for (size_t i = 0; i < G_N_ELEMENTS (types); i++)
{
GType registered_type = gi_base_info_type_register_static (g_intern_static_string (types[i].type_name),
types[i].instance_size,

View File

@ -631,9 +631,9 @@ gboolean
gi_callable_info_invoke (GICallableInfo *info,
void *function,
const GIArgument *in_args,
gsize n_in_args,
size_t n_in_args,
GIArgument *out_args,
gsize n_out_args,
size_t n_out_args,
GIArgument *return_value,
GError **error)
{
@ -644,7 +644,7 @@ gi_callable_info_invoke (GICallableInfo *info,
GITypeInfo *rinfo;
GITypeTag rtag;
GIArgInfo *ainfo;
gsize n_args, n_invoke_args, in_pos, out_pos, i;
size_t n_args, n_invoke_args, in_pos, out_pos, i;
void **args;
gboolean success = FALSE;
GError *local_error = NULL;

View File

@ -95,9 +95,9 @@ GI_AVAILABLE_IN_ALL
gboolean gi_callable_info_invoke (GICallableInfo *info,
void *function,
const GIArgument *in_args,
gsize n_in_args,
size_t n_in_args,
GIArgument *out_args,
gsize n_out_args,
size_t n_out_args,
GIArgument *return_value,
GError **error);

View File

@ -116,7 +116,7 @@ gi_constant_info_free_value (GIConstantInfo *info,
* Returns: size of the constant, in bytes
* Since: 2.80
*/
gsize
size_t
gi_constant_info_get_value (GIConstantInfo *info,
GIArgument *value)
{
@ -133,7 +133,7 @@ gi_constant_info_get_value (GIConstantInfo *info,
{
if (blob->type.flags.pointer)
{
gsize blob_size = blob->size;
size_t blob_size = blob->size;
value->v_pointer = g_memdup2 (&rinfo->typelib->data[blob->offset], blob_size);
}

View File

@ -52,6 +52,6 @@ void gi_constant_info_free_value (GIConstantInfo *info,
GIArgument *value);
GI_AVAILABLE_IN_ALL
gsize gi_constant_info_get_value (GIConstantInfo *info,
size_t gi_constant_info_get_value (GIConstantInfo *info,
GIArgument *value);
G_END_DECLS

View File

@ -95,7 +95,7 @@ gi_field_info_get_flags (GIFieldInfo *info)
* Returns: the field size, in bits
* Since: 2.80
*/
gsize
size_t
gi_field_info_get_size (GIFieldInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
@ -119,7 +119,7 @@ gi_field_info_get_size (GIFieldInfo *info)
* Returns: the field offset, in bytes
* Since: 2.80
*/
gsize
size_t
gi_field_info_get_offset (GIFieldInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
@ -433,7 +433,7 @@ gi_field_info_set_field (GIFieldInfo *field_info,
result = TRUE;
break;
case GI_TYPE_TAG_GTYPE:
G_STRUCT_MEMBER (gsize, mem, offset) = value->v_size;
G_STRUCT_MEMBER (size_t, mem, offset) = value->v_size;
result = TRUE;
break;
case GI_TYPE_TAG_FLOAT:

View File

@ -48,10 +48,10 @@ GI_AVAILABLE_IN_ALL
GIFieldInfoFlags gi_field_info_get_flags (GIFieldInfo *info);
GI_AVAILABLE_IN_ALL
gsize gi_field_info_get_size (GIFieldInfo *info);
size_t gi_field_info_get_size (GIFieldInfo *info);
GI_AVAILABLE_IN_ALL
gsize gi_field_info_get_offset (GIFieldInfo *info);
size_t gi_field_info_get_offset (GIFieldInfo *info);
GI_AVAILABLE_IN_ALL
GITypeInfo * gi_field_info_get_type_info (GIFieldInfo *info);

View File

@ -266,9 +266,9 @@ gi_invoke_error_quark (void)
gboolean
gi_function_info_invoke (GIFunctionInfo *info,
const GIArgument *in_args,
gsize n_in_args,
size_t n_in_args,
GIArgument *out_args,
gsize n_out_args,
size_t n_out_args,
GIArgument *return_value,
GError **error)
{

View File

@ -92,9 +92,9 @@ typedef enum
GI_AVAILABLE_IN_ALL
gboolean gi_function_info_invoke (GIFunctionInfo *info,
const GIArgument *in_args,
gsize n_in_args,
size_t n_in_args,
GIArgument *out_args,
gsize n_out_args,
size_t n_out_args,
GIArgument *return_value,
GError **error);

View File

@ -1071,7 +1071,7 @@ gi_repository_find_by_error_domain (GIRepository *repository,
void
gi_repository_get_object_gtype_interfaces (GIRepository *repository,
GType gtype,
gsize *n_interfaces_out,
size_t *n_interfaces_out,
GIInterfaceInfo ***interfaces_out)
{
GTypeInterfaceCache *cache;

View File

@ -165,7 +165,7 @@ GIBaseInfo * gi_repository_find_by_gtype (GIRepository *repository,
GI_AVAILABLE_IN_ALL
void gi_repository_get_object_gtype_interfaces (GIRepository *repository,
GType gtype,
gsize *n_interfaces_out,
size_t *n_interfaces_out,
GIInterfaceInfo ***interfaces_out);
GI_AVAILABLE_IN_ALL

View File

@ -319,8 +319,8 @@ gi_ir_module_build_typelib (GIIrModule *module)
{
GError *error = NULL;
GITypelib *typelib;
gsize length;
unsigned int i;
size_t length;
size_t i;
GList *e;
Header *header;
DirEntry *entry;

View File

@ -433,7 +433,7 @@ static GIIrNodeType * parse_type_internal (GIIrModule *module,
typedef struct {
const char *str;
unsigned int size;
size_t size;
unsigned int is_signed : 1;
} IntegerAliasInfo;

View File

@ -1249,7 +1249,7 @@ write_union_info (const char *ns,
const char *type_init;
const char *func;
gboolean deprecated;
gsize size;
size_t size;
name = gi_base_info_get_name ((GIBaseInfo *)info);
deprecated = gi_base_info_is_deprecated ((GIBaseInfo *)info);

View File

@ -232,7 +232,7 @@ gi_struct_info_find_method (GIStructInfo *info,
* Returns: size of the structure, in bytes
* Since: 2.80
*/
gsize
size_t
gi_struct_info_get_size (GIStructInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
@ -250,7 +250,7 @@ gi_struct_info_get_size (GIStructInfo *info)
* Returns: required alignment, in bytes
* Since: 2.80
*/
gsize
size_t
gi_struct_info_get_alignment (GIStructInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;

View File

@ -67,10 +67,10 @@ GIFunctionInfo * gi_struct_info_find_method (GIStructInfo *info,
const char *name);
GI_AVAILABLE_IN_ALL
gsize gi_struct_info_get_size (GIStructInfo *info);
size_t gi_struct_info_get_size (GIStructInfo *info);
GI_AVAILABLE_IN_ALL
gsize gi_struct_info_get_alignment (GIStructInfo *info);
size_t gi_struct_info_get_alignment (GIStructInfo *info);
GI_AVAILABLE_IN_ALL
gboolean gi_struct_info_is_gtype_struct (GIStructInfo *info);

View File

@ -1314,7 +1314,7 @@ typedef struct {
struct _GITypelib {
/*< private >*/
uint8_t *data;
gsize len;
size_t len;
gboolean owns_memory;
GMappedFile *mfile;
GList *modules;

View File

@ -271,7 +271,7 @@ gi_typelib_get_dir_entry_by_gtype_name (GITypelib *typelib,
typedef struct {
const char *s;
const char *separator;
gsize sep_len;
size_t sep_len;
GString buf;
} StrSplitIter;
@ -294,7 +294,7 @@ strsplit_iter_next (StrSplitIter *iter,
{
const char *s = iter->s;
const char *next;
gsize len;
size_t len;
if (!s)
return FALSE;
@ -347,7 +347,7 @@ gi_typelib_matches_gtype_name_prefix (GITypelib *typelib,
const char *prefix;
gboolean ret = FALSE;
StrSplitIter split_iter;
gsize gtype_name_len;
size_t gtype_name_len;
c_prefix = gi_typelib_get_string (typelib, header->c_prefix);
if (c_prefix == NULL || strlen (c_prefix) == 0)
@ -558,7 +558,7 @@ validate_name (GITypelib *typelib,
/* Fast path sanity check, operates on a memory blob */
static gboolean
validate_header_basic (const uint8_t *memory,
gsize len,
size_t len,
GError **error)
{
Header *header = (Header *)memory;
@ -568,8 +568,7 @@ validate_header_basic (const uint8_t *memory,
g_set_error (error,
GI_TYPELIB_ERROR,
GI_TYPELIB_ERROR_INVALID,
"The specified typelib length %" G_GSIZE_FORMAT " is too short",
len);
"The specified typelib length %zu is too short", len);
return FALSE;
}
@ -608,8 +607,8 @@ validate_header_basic (const uint8_t *memory,
g_set_error (error,
GI_TYPELIB_ERROR,
GI_TYPELIB_ERROR_INVALID_HEADER,
"Typelib size %" G_GSIZE_FORMAT " does not match %" G_GSIZE_FORMAT,
(gsize) header->size, len);
"Typelib size %zu does not match %zu",
(size_t) header->size, len);
return FALSE;
}
@ -2410,7 +2409,7 @@ gi_typelib_ensure_open (GITypelib *typelib)
*/
GITypelib *
gi_typelib_new_from_memory (uint8_t *memory,
gsize len,
size_t len,
GError **error)
{
GITypelib *meta;
@ -2440,8 +2439,8 @@ gi_typelib_new_from_memory (uint8_t *memory,
*/
GITypelib *
gi_typelib_new_from_const_memory (const uint8_t *memory,
gsize len,
GError **error)
size_t len,
GError **error)
{
GITypelib *meta;
@ -2474,7 +2473,7 @@ gi_typelib_new_from_mapped_file (GMappedFile *mfile,
{
GITypelib *meta;
uint8_t *data = (uint8_t *) g_mapped_file_get_contents (mfile);
gsize len = g_mapped_file_get_length (mfile);
size_t len = g_mapped_file_get_length (mfile);
if (!validate_header_basic (data, len, error))
return NULL;

View File

@ -38,12 +38,12 @@ typedef struct _GITypelib GITypelib;
GI_AVAILABLE_IN_ALL
GITypelib * gi_typelib_new_from_memory (uint8_t *memory,
gsize len,
size_t len,
GError **error);
GI_AVAILABLE_IN_ALL
GITypelib * gi_typelib_new_from_const_memory (const uint8_t *memory,
gsize len,
size_t len,
GError **error);
GI_AVAILABLE_IN_ALL

View File

@ -133,7 +133,7 @@ union _GIArgument
long v_long;
unsigned long v_ulong;
gssize v_ssize;
gsize v_size;
size_t v_size;
char *v_string;
void *v_pointer;
};

View File

@ -260,7 +260,7 @@ gi_union_info_find_method (GIUnionInfo *info,
* Returns: size of the union, in bytes
* Since: 2.80
*/
gsize
size_t
gi_union_info_get_size (GIUnionInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
@ -278,7 +278,7 @@ gi_union_info_get_size (GIUnionInfo *info)
* Returns: required alignment, in bytes
* Since: 2.80
*/
gsize
size_t
gi_union_info_get_alignment (GIUnionInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;

View File

@ -75,10 +75,10 @@ GIFunctionInfo * gi_union_info_find_method (GIUnionInfo *info,
const char *name);
GI_AVAILABLE_IN_ALL
gsize gi_union_info_get_size (GIUnionInfo *info);
size_t gi_union_info_get_size (GIUnionInfo *info);
GI_AVAILABLE_IN_ALL
gsize gi_union_info_get_alignment (GIUnionInfo *info);
size_t gi_union_info_get_alignment (GIUnionInfo *info);
GI_AVAILABLE_IN_ALL
const char * gi_union_info_get_copy_function_name (GIUnionInfo *info);

View File

@ -341,9 +341,9 @@ gboolean
gi_vfunc_info_invoke (GIVFuncInfo *info,
GType implementor,
const GIArgument *in_args,
gsize n_in_args,
size_t n_in_args,
GIArgument *out_args,
gsize n_out_args,
size_t n_out_args,
GIArgument *return_value,
GError **error)
{

View File

@ -64,9 +64,9 @@ GI_AVAILABLE_IN_ALL
gboolean gi_vfunc_info_invoke (GIVFuncInfo *info,
GType implementor,
const GIArgument *in_args,
gsize n_in_args,
size_t n_in_args,
GIArgument *out_args,
gsize n_out_args,
size_t n_out_args,
GIArgument *return_value,
GError **error);