[gobject-introspection] [girepository] Use g_slice
- From: Johan Dahlin <johan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] [girepository] Use g_slice
- Date: Thu, 20 May 2010 14:41:59 +0000 (UTC)
commit 891ba6c46a19e647f063e12131823e61f40f9c98
Author: Johan Dahlin <johan gnome org>
Date: Thu May 20 11:33:49 2010 -0300
[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.
girepository/ginfo.c | 8 ++++----
girepository/girepository.c | 6 +++---
girepository/girmodule.c | 4 ++--
girepository/gtypelib.c | 8 ++++----
4 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/girepository/ginfo.c b/girepository/ginfo.c
index 6dad782..a404059 100644
--- a/girepository/ginfo.c
+++ b/girepository/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);
}
}
diff --git a/girepository/girepository.c b/girepository/girepository.c
index 684db66..218a954 100644
--- a/girepository/girepository.c
+++ b/girepository/girepository.c
@@ -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);
}
diff --git a/girepository/girmodule.c b/girepository/girmodule.c
index 66efceb..b380912 100644
--- a/girepository/girmodule.c
+++ b/girepository/girmodule.c
@@ -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);
}
/**
diff --git a/girepository/gtypelib.c b/girepository/gtypelib.c
index 463996c..41bbb0c 100644
--- a/girepository/gtypelib.c
+++ b/girepository/gtypelib.c
@@ -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 *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]