mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-24 19:22:11 +01:00
[girepository] Use g_slice
Use g_slice to allocate instead of g_new(x, 1); It uses a memory pool internally and should be faster, especially for GBaseInfo/GRealInfo, structs which are tiny.
This commit is contained in:
parent
cc270b03d6
commit
7e2e379388
8
ginfo.c
8
ginfo.c
@ -107,7 +107,7 @@ g_info_new_full (GIInfoType type,
|
||||
|
||||
g_return_val_if_fail (container != NULL || repository != NULL, NULL);
|
||||
|
||||
info = g_new (GIRealInfo, 1);
|
||||
info = g_slice_new (GIRealInfo);
|
||||
|
||||
g_info_init (info, type, repository, container, typelib, offset);
|
||||
info->ref_count = 1;
|
||||
@ -149,7 +149,7 @@ g_info_from_entry (GIRepository *repository,
|
||||
{
|
||||
GIUnresolvedInfo *unresolved;
|
||||
|
||||
unresolved = g_new0 (GIUnresolvedInfo, 1);
|
||||
unresolved = g_slice_new0 (GIUnresolvedInfo);
|
||||
|
||||
unresolved->type = GI_INFO_TYPE_UNRESOLVED;
|
||||
unresolved->ref_count = 1;
|
||||
@ -159,7 +159,7 @@ g_info_from_entry (GIRepository *repository,
|
||||
unresolved->namespace = namespace;
|
||||
|
||||
return (GIBaseInfo *)unresolved;
|
||||
}
|
||||
}
|
||||
return (GIBaseInfo *)result;
|
||||
}
|
||||
|
||||
@ -241,7 +241,7 @@ g_base_info_unref (GIBaseInfo *info)
|
||||
if (rinfo->repository)
|
||||
g_object_unref (rinfo->repository);
|
||||
|
||||
g_free (rinfo);
|
||||
g_slice_free (GIRealInfo, rinfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1043,7 +1043,7 @@ free_candidate (struct NamespaceVersionCandidadate *candidate)
|
||||
g_mapped_file_unref (candidate->mfile);
|
||||
g_free (candidate->path);
|
||||
g_free (candidate->version);
|
||||
g_free (candidate);
|
||||
g_slice_free (struct NamespaceVersionCandidadate, candidate);
|
||||
}
|
||||
|
||||
static GMappedFile *
|
||||
@ -1111,7 +1111,7 @@ find_namespace_latest (const gchar *namespace,
|
||||
g_clear_error (&error);
|
||||
continue;
|
||||
}
|
||||
candidate = g_new0 (struct NamespaceVersionCandidadate, 1);
|
||||
candidate = g_slice_new0 (struct NamespaceVersionCandidadate);
|
||||
candidate->mfile = mfile;
|
||||
candidate->path_index = index;
|
||||
candidate->path = path;
|
||||
@ -1134,7 +1134,7 @@ find_namespace_latest (const gchar *namespace,
|
||||
result = elected->mfile;
|
||||
*path_ret = elected->path;
|
||||
*version_ret = elected->version;
|
||||
g_free (elected); /* just free the container */
|
||||
g_slice_free (struct NamespaceVersionCandidadate, elected); /* just free the container */
|
||||
g_slist_foreach (candidates, (GFunc) free_candidate, NULL);
|
||||
g_slist_free (candidates);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ g_ir_module_new (const gchar *name,
|
||||
{
|
||||
GIrModule *module;
|
||||
|
||||
module = g_new0 (GIrModule, 1);
|
||||
module = g_slice_new0 (GIrModule);
|
||||
|
||||
module->name = g_strdup (name);
|
||||
module->version = g_strdup (version);
|
||||
@ -73,7 +73,7 @@ g_ir_module_free (GIrModule *module)
|
||||
g_hash_table_destroy (module->aliases);
|
||||
g_hash_table_destroy (module->disguised_structures);
|
||||
|
||||
g_free (module);
|
||||
g_slice_free (GIrModule, module);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2071,7 +2071,7 @@ g_typelib_new_from_memory (guchar *memory, gsize len)
|
||||
{
|
||||
GTypelib *meta;
|
||||
|
||||
meta = g_new0 (GTypelib, 1);
|
||||
meta = g_slice_new0 (GTypelib);
|
||||
meta->data = memory;
|
||||
meta->len = len;
|
||||
meta->owns_memory = TRUE;
|
||||
@ -2094,7 +2094,7 @@ g_typelib_new_from_const_memory (const guchar *memory, gsize len)
|
||||
{
|
||||
GTypelib *meta;
|
||||
|
||||
meta = g_new0 (GTypelib, 1);
|
||||
meta = g_slice_new0 (GTypelib);
|
||||
meta->data = (guchar *) memory;
|
||||
meta->len = len;
|
||||
meta->owns_memory = FALSE;
|
||||
@ -2116,7 +2116,7 @@ g_typelib_new_from_mapped_file (GMappedFile *mfile)
|
||||
{
|
||||
GTypelib *meta;
|
||||
|
||||
meta = g_new0 (GTypelib, 1);
|
||||
meta = g_slice_new0 (GTypelib);
|
||||
meta->mfile = mfile;
|
||||
meta->owns_memory = FALSE;
|
||||
meta->data = (guchar *) g_mapped_file_get_contents (mfile);
|
||||
@ -2144,7 +2144,7 @@ g_typelib_free (GTypelib *typelib)
|
||||
g_list_foreach (typelib->modules, (GFunc) g_module_close, NULL);
|
||||
g_list_free (typelib->modules);
|
||||
}
|
||||
g_free (typelib);
|
||||
g_slice_free (GTypelib, typelib);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
|
Loading…
x
Reference in New Issue
Block a user