[glib: 6/9] ghash: Use realloc in place of alloc for key/value
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 6/9] ghash: Use realloc in place of alloc for key/value
- Date: Wed, 10 Oct 2018 23:02:33 +0000 (UTC)
commit 99863956384a7adda43030ff9f888f837a5c5e5a
Author: Hans Petter Jansson <hpj cl no>
Date: Mon Jul 30 15:08:49 2018 +0200
ghash: Use realloc in place of alloc for key/value
Minor simplification resulting in the removal of redundant alloc wrappers.
glib/ghash.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
---
diff --git a/glib/ghash.c b/glib/ghash.c
index 83252b833..d305530a8 100644
--- a/glib/ghash.c
+++ b/glib/ghash.c
@@ -365,17 +365,7 @@ g_hash_table_set_shift_from_size (GHashTable *hash_table, gint size)
}
static inline gpointer
-g_hash_table_alloc_key_or_value_array (guint size, gboolean is_big G_GNUC_UNUSED)
-{
-#ifdef USE_SMALL_ARRAYS
- return g_malloc0 (size * (is_big ? BIG_ENTRY_SIZE : SMALL_ENTRY_SIZE));
-#else
- return g_new0 (gpointer, size);
-#endif
-}
-
-static inline gpointer
-g_hash_table_realloc_key_or_value_array (gpointer a, guint size, gboolean is_big G_GNUC_UNUSED)
+g_hash_table_realloc_key_or_value_array (gpointer a, guint size, G_GNUC_UNUSED gboolean is_big)
{
#ifdef USE_SMALL_ARRAYS
return g_realloc (a, size * (is_big ? BIG_ENTRY_SIZE : SMALL_ENTRY_SIZE));
@@ -630,7 +620,7 @@ g_hash_table_remove_all_nodes (GHashTable *hash_table,
g_hash_table_set_shift (hash_table, HASH_TABLE_MIN_SHIFT);
if (!destruction)
{
- hash_table->keys = g_hash_table_alloc_key_or_value_array (hash_table->size, FALSE);
+ hash_table->keys = g_hash_table_realloc_key_or_value_array (NULL, hash_table->size, FALSE);
hash_table->values = hash_table->keys;
hash_table->hashes = g_new0 (guint, hash_table->size);
}
@@ -1037,7 +1027,7 @@ g_hash_table_new_full (GHashFunc hash_func,
#endif
hash_table->key_destroy_func = key_destroy_func;
hash_table->value_destroy_func = value_destroy_func;
- hash_table->keys = g_hash_table_alloc_key_or_value_array (hash_table->size, FALSE);
+ hash_table->keys = g_hash_table_realloc_key_or_value_array (NULL, hash_table->size, FALSE);
hash_table->values = hash_table->keys;
hash_table->hashes = g_new0 (guint, hash_table->size);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]