From ce1cba0884349134d5adbc4545f7514e2dddb35f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 3 Feb 2023 11:10:49 +0100 Subject: [PATCH] Revert "gtype: Use the system allocator on UNIX" Since commit 45b5a6c0 GSlice is just a wrapper to g_malloc0/g_free, so there's no point to use a different implementation for UNIXes vs windows. This reverts commit 3b7af4dd5da919b29bf77c47251c12edf5ed07d1. --- gobject/gtype.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/gobject/gtype.c b/gobject/gtype.c index 8665db294..3facf97f1 100644 --- a/gobject/gtype.c +++ b/gobject/gtype.c @@ -1874,18 +1874,6 @@ maybe_issue_deprecation_warning (GType type) name); } -/* We use the system allocator on UNIX-y systems, where we know we have - * access to a decent allocator. On other systems, we fall back to the - * slice allocator, as we know its performance profile - */ -#ifdef G_OS_UNIX -# define instance_alloc(s) g_malloc0 ((s)) -# define instance_free(s,p) g_free ((p)) -#else -# define instance_alloc(s) g_slice_alloc0 ((s)) -# define instance_free(s,p) g_slice_free1 ((s),(p)) -#endif - /** * g_type_create_instance: (skip) * @type: an instantiatable type to create an instance for @@ -1966,7 +1954,7 @@ g_type_create_instance (GType type) private_size += ALIGN_STRUCT (1); /* Allocate one extra pointer size... */ - allocated = instance_alloc (private_size + ivar_size + sizeof (gpointer)); + allocated = g_slice_alloc0 (private_size + ivar_size + sizeof (gpointer)); /* ... and point it back to the start of the private data. */ *(gpointer *) (allocated + private_size + ivar_size) = allocated + ALIGN_STRUCT (1); @@ -1976,7 +1964,7 @@ g_type_create_instance (GType type) } else #endif - allocated = instance_alloc (private_size + ivar_size); + allocated = g_slice_alloc0 (private_size + ivar_size); instance = (GTypeInstance *) (allocated + private_size); @@ -2066,14 +2054,14 @@ g_type_free_instance (GTypeInstance *instance) /* Clear out the extra pointer... */ *(gpointer *) (allocated + private_size + ivar_size) = NULL; /* ... and ensure we include it in the size we free. */ - instance_free (private_size + ivar_size + sizeof (gpointer), allocated); + g_slice_free1 (private_size + ivar_size + sizeof (gpointer), allocated); VALGRIND_FREELIKE_BLOCK (allocated + ALIGN_STRUCT (1), 0); VALGRIND_FREELIKE_BLOCK (instance, 0); } else #endif - instance_free (private_size + ivar_size, allocated); + g_slice_free1 (private_size + ivar_size, allocated); #ifdef G_ENABLE_DEBUG IF_DEBUG (INSTANCE_COUNT)