From 69e9ba80e2f4d2061a1a68d72bae1c32c1e4f8fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 3 Feb 2023 11:35:10 +0100 Subject: [PATCH] gtype: Use g_malloc0 and g_free_sized to allocate and free memory We've a sized free now, so we can just use it! --- gobject/gtype.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gobject/gtype.c b/gobject/gtype.c index 3facf97f1..dfb0c0e09 100644 --- a/gobject/gtype.c +++ b/gobject/gtype.c @@ -1954,7 +1954,7 @@ g_type_create_instance (GType type) private_size += ALIGN_STRUCT (1); /* Allocate one extra pointer size... */ - allocated = g_slice_alloc0 (private_size + ivar_size + sizeof (gpointer)); + allocated = g_malloc0 (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); @@ -1964,7 +1964,7 @@ g_type_create_instance (GType type) } else #endif - allocated = g_slice_alloc0 (private_size + ivar_size); + allocated = g_malloc0 (private_size + ivar_size); instance = (GTypeInstance *) (allocated + private_size); @@ -2054,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. */ - g_slice_free1 (private_size + ivar_size + sizeof (gpointer), allocated); + g_free_sized (allocated, private_size + ivar_size + sizeof (gpointer)); VALGRIND_FREELIKE_BLOCK (allocated + ALIGN_STRUCT (1), 0); VALGRIND_FREELIKE_BLOCK (instance, 0); } else #endif - g_slice_free1 (private_size + ivar_size, allocated); + g_free_sized (allocated, private_size + ivar_size); #ifdef G_ENABLE_DEBUG IF_DEBUG (INSTANCE_COUNT)