From 9f88dba1622a02b44f49fc0079b7810e588347d3 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 3 Mar 2023 06:48:49 -0500 Subject: [PATCH] gsk: Stop using g_slice --- gsk/gl/gskgldriver.c | 10 +++++----- gsk/gl/gskglglyphlibrary.c | 4 ++-- gsk/gl/gskglglyphlibraryprivate.h | 4 +++- gsk/gl/gskgliconlibrary.c | 2 +- gsk/gl/gskglrenderjob.c | 4 ++-- gsk/gl/gskgltexture.c | 4 ++-- gsk/gl/gskgltexturelibrary.c | 6 +++--- gsk/gskdiff.c | 4 ++-- gsk/gskprofiler.c | 10 ++++------ gsk/vulkan/gskvulkanbuffer.c | 4 ++-- gsk/vulkan/gskvulkancommandpool.c | 4 ++-- gsk/vulkan/gskvulkanimage.c | 4 ++-- gsk/vulkan/gskvulkanmemory.c | 4 ++-- gsk/vulkan/gskvulkanrender.c | 10 +++++----- gsk/vulkan/gskvulkanrenderer.c | 6 +++--- gsk/vulkan/gskvulkanrenderpass.c | 4 ++-- gsk/vulkan/gskvulkanshader.c | 4 ++-- 17 files changed, 44 insertions(+), 44 deletions(-) diff --git a/gsk/gl/gskgldriver.c b/gsk/gl/gskgldriver.c index 727ce079bb..64382f40e6 100644 --- a/gsk/gl/gskgldriver.c +++ b/gsk/gl/gskgldriver.c @@ -619,7 +619,7 @@ gsk_gl_driver_after_frame (GskGLDriver *self) gsk_gl_driver_autorelease_framebuffer (self, render_target->framebuffer_id); gsk_gl_driver_autorelease_texture (self, render_target->texture_id); - g_slice_free (GskGLRenderTarget, render_target); + g_free (render_target); self->render_targets->len--; } @@ -935,7 +935,7 @@ gsk_gl_driver_create_render_target (GskGLDriver *self, { GskGLRenderTarget *render_target; - render_target = g_slice_new0 (GskGLRenderTarget); + render_target = g_new0 (GskGLRenderTarget, 1); render_target->min_filter = min_filter; render_target->mag_filter = mag_filter; render_target->format = format; @@ -1007,7 +1007,7 @@ gsk_gl_driver_release_render_target (GskGLDriver *self, g_steal_pointer (&texture)); gsk_gl_driver_autorelease_framebuffer (self, render_target->framebuffer_id); - g_slice_free (GskGLRenderTarget, render_target); + g_free (render_target); } @@ -1341,7 +1341,7 @@ create_texture_from_texture_destroy (gpointer data) gdk_gl_context_make_current (state->context); glDeleteTextures (1, &state->texture_id); g_clear_object (&state->context); - g_slice_free (GskGLTextureState, state); + g_free (state); } GdkTexture * @@ -1362,7 +1362,7 @@ gsk_gl_driver_create_gdk_texture (GskGLDriver *self, if (!(texture = g_hash_table_lookup (self->textures, GUINT_TO_POINTER (texture_id)))) g_return_val_if_reached (NULL); - state = g_slice_new0 (GskGLTextureState); + state = g_new0 (GskGLTextureState, 1); state->texture_id = texture_id; state->context = g_object_ref (self->command_queue->context); diff --git a/gsk/gl/gskglglyphlibrary.c b/gsk/gl/gskglglyphlibrary.c index aa22646b5f..22ffeb0324 100644 --- a/gsk/gl/gskglglyphlibrary.c +++ b/gsk/gl/gskglglyphlibrary.c @@ -74,13 +74,13 @@ gsk_gl_glyph_key_free (gpointer data) GskGLGlyphKey *key = data; g_clear_object (&key->font); - g_slice_free (GskGLGlyphKey, key); + g_free (key); } static void gsk_gl_glyph_value_free (gpointer data) { - g_slice_free (GskGLGlyphValue, data); + g_free (data); } static void diff --git a/gsk/gl/gskglglyphlibraryprivate.h b/gsk/gl/gskglglyphlibraryprivate.h index 2ed051358e..42692f34e6 100644 --- a/gsk/gl/gskglglyphlibraryprivate.h +++ b/gsk/gl/gskglglyphlibraryprivate.h @@ -88,7 +88,9 @@ gsk_gl_glyph_library_lookup_or_add (GskGLGlyphLibrary *self, } else { - GskGLGlyphKey *k = g_slice_copy (sizeof *key, key); + GskGLGlyphKey *k; + k = g_new (GskGLGlyphKey, 1); + memcpy (k, key, sizeof (GskGLGlyphKey)); g_object_ref (k->font); gsk_gl_glyph_library_add (self, k, out_value); self->front[front_index].key = *key; diff --git a/gsk/gl/gskgliconlibrary.c b/gsk/gl/gskgliconlibrary.c index f4686fd877..58e5a22be9 100644 --- a/gsk/gl/gskgliconlibrary.c +++ b/gsk/gl/gskgliconlibrary.c @@ -52,7 +52,7 @@ gsk_gl_icon_data_free (gpointer data) GskGLIconData *icon_data = data; g_clear_object (&icon_data->source_texture); - g_slice_free (GskGLIconData, icon_data); + g_free (icon_data); } static void diff --git a/gsk/gl/gskglrenderjob.c b/gsk/gl/gskglrenderjob.c index 30d7c9cc51..53a759e293 100644 --- a/gsk/gl/gskglrenderjob.c +++ b/gsk/gl/gskglrenderjob.c @@ -4374,7 +4374,7 @@ gsk_gl_render_job_new (GskGLDriver *driver, if (framebuffer == 0 && default_framebuffer != 0) framebuffer = default_framebuffer; - job = g_slice_new0 (GskGLRenderJob); + job = g_new0 (GskGLRenderJob, 1); job->driver = g_object_ref (driver); job->command_queue = job->driver->command_queue; job->clip = g_array_sized_new (FALSE, FALSE, sizeof (GskGLRenderClip), 16); @@ -4439,5 +4439,5 @@ gsk_gl_render_job_free (GskGLRenderJob *job) g_clear_pointer (&job->region, cairo_region_destroy); g_clear_pointer (&job->modelview, g_array_unref); g_clear_pointer (&job->clip, g_array_unref); - g_slice_free (GskGLRenderJob, job); + g_free (job); } diff --git a/gsk/gl/gskgltexture.c b/gsk/gl/gskgltexture.c index 6ff56e6978..c6dfa98ba7 100644 --- a/gsk/gl/gskgltexture.c +++ b/gsk/gl/gskgltexture.c @@ -51,7 +51,7 @@ gsk_gl_texture_free (GskGLTexture *texture) g_clear_pointer (&texture->slices, g_free); g_clear_pointer (&texture->nine_slice, g_free); - g_slice_free (GskGLTexture, texture); + g_free (texture); } } @@ -66,7 +66,7 @@ gsk_gl_texture_new (guint texture_id, { GskGLTexture *texture; - texture = g_slice_new0 (GskGLTexture); + texture = g_new0 (GskGLTexture, 1); texture->texture_id = texture_id; texture->link.data = texture; texture->min_filter = min_filter; diff --git a/gsk/gl/gskgltexturelibrary.c b/gsk/gl/gskgltexturelibrary.c index 6cbd7fa32a..a1cf4c1b12 100644 --- a/gsk/gl/gskgltexturelibrary.c +++ b/gsk/gl/gskgltexturelibrary.c @@ -52,7 +52,7 @@ gsk_gl_texture_atlas_free (GskGLTextureAtlas *atlas) } g_clear_pointer (&atlas->nodes, g_free); - g_slice_free (GskGLTextureAtlas, atlas); + g_free (atlas); } static gboolean @@ -388,7 +388,7 @@ gsk_gl_texture_library_pack (GskGLTextureLibrary *self, g_assert (out_packed_x != NULL); g_assert (out_packed_y != NULL); - entry = g_slice_alloc0 (valuelen); + entry = g_malloc0 (valuelen); entry->n_pixels = width * height; entry->accessed = TRUE; entry->used = TRUE; @@ -542,7 +542,7 @@ gsk_gl_texture_library_acquire_atlas (GskGLTextureLibrary *self) g_return_val_if_fail (self->atlas_width > 0, NULL); g_return_val_if_fail (self->atlas_height > 0, NULL); - atlas = g_slice_new0 (GskGLTextureAtlas); + atlas = g_new0 (GskGLTextureAtlas, 1); atlas->width = self->atlas_width; atlas->height = self->atlas_height; /* TODO: We might want to change the strategy about the amount of diff --git a/gsk/gskdiff.c b/gsk/gskdiff.c index dd2057e042..9be61184f8 100644 --- a/gsk/gskdiff.c +++ b/gsk/gskdiff.c @@ -53,7 +53,7 @@ gsk_diff_settings_new (GCompareDataFunc compare_func, { GskDiffSettings *settings; - settings = g_slice_new0 (GskDiffSettings); + settings = g_new0 (GskDiffSettings, 1); settings->compare_func = compare_func; settings->keep_func = keep_func; @@ -73,7 +73,7 @@ gsk_diff_settings_set_allow_abort (GskDiffSettings *settings, void gsk_diff_settings_free (GskDiffSettings *settings) { - g_slice_free (GskDiffSettings, settings); + g_free (settings); } /* diff --git a/gsk/gskprofiler.c b/gsk/gskprofiler.c index e9ef91af93..a34844eb70 100644 --- a/gsk/gskprofiler.c +++ b/gsk/gskprofiler.c @@ -53,8 +53,7 @@ named_counter_free (gpointer data) return; g_free (counter->description); - - g_slice_free (NamedCounter, counter); + g_free (counter); } static void @@ -66,8 +65,7 @@ named_timer_free (gpointer data) return; g_free (timer->description); - - g_slice_free (NamedTimer, timer); + g_free (timer); } static void @@ -109,7 +107,7 @@ named_counter_new (GQuark id, const char *description, gboolean can_reset) { - NamedCounter *res = g_slice_new0 (NamedCounter); + NamedCounter *res = g_new0 (NamedCounter, 1); res->id = id; res->description = g_strdup (description); @@ -156,7 +154,7 @@ named_timer_new (GQuark id, gboolean invert, gboolean can_reset) { - NamedTimer *res = g_slice_new0 (NamedTimer); + NamedTimer *res = g_new0 (NamedTimer, 1); res->id = id; res->description = g_strdup (description); diff --git a/gsk/vulkan/gskvulkanbuffer.c b/gsk/vulkan/gskvulkanbuffer.c index 291e340170..b73907faea 100644 --- a/gsk/vulkan/gskvulkanbuffer.c +++ b/gsk/vulkan/gskvulkanbuffer.c @@ -23,7 +23,7 @@ gsk_vulkan_buffer_new_internal (GdkVulkanContext *context, VkMemoryRequirements requirements; GskVulkanBuffer *self; - self = g_slice_new0 (GskVulkanBuffer); + self = g_new0 (GskVulkanBuffer, 1); self->vulkan = g_object_ref (context); self->size = size; @@ -88,7 +88,7 @@ gsk_vulkan_buffer_free (GskVulkanBuffer *self) g_object_unref (self->vulkan); - g_slice_free (GskVulkanBuffer, self); + g_free (self); } VkBuffer diff --git a/gsk/vulkan/gskvulkancommandpool.c b/gsk/vulkan/gskvulkancommandpool.c index 0afb59c24d..8adb6c5bf4 100644 --- a/gsk/vulkan/gskvulkancommandpool.c +++ b/gsk/vulkan/gskvulkancommandpool.c @@ -16,7 +16,7 @@ gsk_vulkan_command_pool_new (GdkVulkanContext *context) { GskVulkanCommandPool *self; - self = g_slice_new0 (GskVulkanCommandPool); + self = g_new0 (GskVulkanCommandPool, 1); self->vulkan = g_object_ref (context); @@ -56,7 +56,7 @@ gsk_vulkan_command_pool_free (GskVulkanCommandPool *self) self->vk_command_pool, NULL); - g_slice_free (GskVulkanCommandPool, self); + g_free (self); } void diff --git a/gsk/vulkan/gskvulkanimage.c b/gsk/vulkan/gskvulkanimage.c index b73578afde..b74eb76fb0 100644 --- a/gsk/vulkan/gskvulkanimage.c +++ b/gsk/vulkan/gskvulkanimage.c @@ -49,7 +49,7 @@ gsk_vulkan_uploader_new (GdkVulkanContext *context, { GskVulkanUploader *self; - self = g_slice_new0 (GskVulkanUploader); + self = g_new0 (GskVulkanUploader, 1); self->vulkan = g_object_ref (context); self->command_pool = command_pool; @@ -75,7 +75,7 @@ gsk_vulkan_uploader_free (GskVulkanUploader *self) g_object_unref (self->vulkan); - g_slice_free (GskVulkanUploader, self); + g_free (self); } static void diff --git a/gsk/vulkan/gskvulkanmemory.c b/gsk/vulkan/gskvulkanmemory.c index 1ff46757d4..abe59b4808 100644 --- a/gsk/vulkan/gskvulkanmemory.c +++ b/gsk/vulkan/gskvulkanmemory.c @@ -22,7 +22,7 @@ gsk_vulkan_memory_new (GdkVulkanContext *context, GskVulkanMemory *self; uint32_t i; - self = g_slice_new0 (GskVulkanMemory); + self = g_new0 (GskVulkanMemory, 1); self->vulkan = g_object_ref (context); self->size = size; @@ -62,7 +62,7 @@ gsk_vulkan_memory_free (GskVulkanMemory *self) g_object_unref (self->vulkan); - g_slice_free (GskVulkanMemory, self); + g_free (self); } VkDeviceMemory diff --git a/gsk/vulkan/gskvulkanrender.c b/gsk/vulkan/gskvulkanrender.c index 29c54aae3a..f2670f697f 100644 --- a/gsk/vulkan/gskvulkanrender.c +++ b/gsk/vulkan/gskvulkanrender.c @@ -113,7 +113,7 @@ gsk_vulkan_render_new (GskRenderer *renderer, GskVulkanRender *self; VkDevice device; - self = g_slice_new0 (GskVulkanRender); + self = g_new0 (GskVulkanRender, 1); self->vulkan = context; self->renderer = renderer; @@ -281,7 +281,7 @@ gsk_vulkan_render_remove_framebuffer_from_image (gpointer data, fb->framebuffer, NULL); - g_slice_free (HashFramebufferEntry, fb); + g_free (fb); } VkFramebuffer @@ -294,7 +294,7 @@ gsk_vulkan_render_get_framebuffer (GskVulkanRender *self, if (fb) return fb->framebuffer; - fb = g_slice_new0 (HashFramebufferEntry); + fb = g_new0 (HashFramebufferEntry, 1); GSK_VK_CHECK (vkCreateFramebuffer, gdk_vulkan_context_get_device (self->vulkan), &(VkFramebufferCreateInfo) { .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, @@ -705,7 +705,7 @@ gsk_vulkan_render_free (GskVulkanRender *self) vkDestroyFramebuffer (gdk_vulkan_context_get_device (self->vulkan), fb->framebuffer, NULL); - g_slice_free (HashFramebufferEntry, fb); + g_free (fb); g_object_weak_unref (G_OBJECT (key), gsk_vulkan_render_remove_framebuffer_from_image, self); g_hash_table_iter_remove (&iter); } @@ -749,7 +749,7 @@ gsk_vulkan_render_free (GskVulkanRender *self) gsk_vulkan_command_pool_free (self->command_pool); - g_slice_free (GskVulkanRender, self); + g_free (self); } gboolean diff --git a/gsk/vulkan/gskvulkanrenderer.c b/gsk/vulkan/gskvulkanrenderer.c index 86f7984805..8f4fa13bf5 100644 --- a/gsk/vulkan/gskvulkanrenderer.c +++ b/gsk/vulkan/gskvulkanrenderer.c @@ -326,7 +326,7 @@ gsk_vulkan_renderer_clear_texture (gpointer p) g_object_unref (data->image); - g_slice_free (GskVulkanTextureData, data); + g_free (data); } GskVulkanImage * @@ -350,7 +350,7 @@ gsk_vulkan_renderer_ref_texture_image (GskVulkanRenderer *self, cairo_image_surface_get_stride (surface)); cairo_surface_destroy (surface); - data = g_slice_new0 (GskVulkanTextureData); + data = g_new0 (GskVulkanTextureData, 1); data->image = image; data->texture = texture; data->renderer = self; @@ -362,7 +362,7 @@ gsk_vulkan_renderer_ref_texture_image (GskVulkanRenderer *self, } else { - g_slice_free (GskVulkanTextureData, data); + g_free (data); } return image; diff --git a/gsk/vulkan/gskvulkanrenderpass.c b/gsk/vulkan/gskvulkanrenderpass.c index 38a2f806e5..f5b1f989e5 100644 --- a/gsk/vulkan/gskvulkanrenderpass.c +++ b/gsk/vulkan/gskvulkanrenderpass.c @@ -140,7 +140,7 @@ gsk_vulkan_render_pass_new (GdkVulkanContext *context, GskVulkanRenderPass *self; VkImageLayout final_layout; - self = g_slice_new0 (GskVulkanRenderPass); + self = g_new0 (GskVulkanRenderPass, 1); self->vulkan = g_object_ref (context); self->render_ops = g_array_new (FALSE, FALSE, sizeof (GskVulkanOp)); @@ -231,7 +231,7 @@ gsk_vulkan_render_pass_free (GskVulkanRenderPass *self) g_array_unref (self->wait_semaphores); - g_slice_free (GskVulkanRenderPass, self); + g_free (self); } #define FALLBACK(...) G_STMT_START { \ diff --git a/gsk/vulkan/gskvulkanshader.c b/gsk/vulkan/gskvulkanshader.c index bd7475a7f0..1450f31e2b 100644 --- a/gsk/vulkan/gskvulkanshader.c +++ b/gsk/vulkan/gskvulkanshader.c @@ -37,7 +37,7 @@ gsk_vulkan_shader_new_from_bytes (GdkVulkanContext *context, return NULL; } - self = g_slice_new0 (GskVulkanShader); + self = g_new0 (GskVulkanShader, 1); self->vulkan = g_object_ref (context); self->type = type; @@ -85,7 +85,7 @@ gsk_vulkan_shader_free (GskVulkanShader *self) g_object_unref (self->vulkan); - g_slice_free (GskVulkanShader, self); + g_free (self); } GskVulkanShaderType