ttml: drop use of GSlice

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3695>
This commit is contained in:
Tim-Philipp Müller 2023-01-08 18:08:34 +00:00 committed by GStreamer Marge Bot
parent c095a1d620
commit 664d83de99
3 changed files with 30 additions and 30 deletions

View file

@ -273,7 +273,7 @@ gst_ttml_render_class_init (GstTtmlRenderClass * klass)
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_ttml_render_change_state);
klass->pango_lock = g_slice_new (GMutex);
klass->pango_lock = g_new (GMutex, 1);
g_mutex_init (klass->pango_lock);
}
@ -1228,7 +1228,7 @@ gst_ttml_render_draw_rectangle (guint width, guint height,
static void
gst_ttml_render_char_range_free (CharRange * range)
{
g_slice_free (CharRange, range);
g_free (range);
}
@ -1301,7 +1301,7 @@ gst_ttml_render_unified_element_free (UnifiedElement * unified_element)
gst_subtitle_element_unref (unified_element->element);
g_free (unified_element->text);
g_slice_free (UnifiedElement, unified_element);
g_free (unified_element);
}
@ -1313,7 +1313,7 @@ gst_ttml_render_unified_element_copy (const UnifiedElement * unified_element)
if (!unified_element)
return NULL;
ret = g_slice_new0 (UnifiedElement);
ret = g_new0 (UnifiedElement, 1);
ret->element = gst_subtitle_element_ref (unified_element->element);
ret->pango_font_size = unified_element->pango_font_size;
ret->pango_font_metrics.height = unified_element->pango_font_metrics.height;
@ -1334,7 +1334,7 @@ gst_ttml_render_unified_block_free (UnifiedBlock * unified_block)
gst_subtitle_style_set_unref (unified_block->style_set);
g_ptr_array_unref (unified_block->unified_elements);
g_free (unified_block->joined_text);
g_slice_free (UnifiedBlock, unified_block);
g_free (unified_block);
}
@ -1358,7 +1358,7 @@ gst_ttml_render_unified_block_copy (const UnifiedBlock * block)
if (!block)
return NULL;
ret = g_slice_new0 (UnifiedBlock);
ret = g_new0 (UnifiedBlock, 1);
ret->joined_text = g_strdup (block->joined_text);
ret->style_set = gst_subtitle_style_set_ref (block->style_set);
ret->unified_elements = g_ptr_array_new_with_free_func ((GDestroyNotify)
@ -1485,7 +1485,7 @@ static UnifiedBlock *
gst_ttml_render_unify_block (GstTtmlRender * render,
const GstSubtitleBlock * block, GstBuffer * buf)
{
UnifiedBlock *ret = g_slice_new0 (UnifiedBlock);
UnifiedBlock *ret = g_new0 (UnifiedBlock, 1);
guint i;
ret->unified_elements = g_ptr_array_new_with_free_func ((GDestroyNotify)
@ -1495,7 +1495,7 @@ gst_ttml_render_unify_block (GstTtmlRender * render,
for (i = 0; i < gst_subtitle_block_get_element_count (block); ++i) {
gchar *text;
UnifiedElement *ue = g_slice_new0 (UnifiedElement);
UnifiedElement *ue = g_new0 (UnifiedElement, 1);
ue->element =
gst_subtitle_element_ref (gst_subtitle_block_get_element (block, i));
ue->pango_font_size =
@ -1584,7 +1584,7 @@ gst_ttml_render_get_line_char_ranges (GstTtmlRender * render,
/* Handle hard breaks in block text. */
while (start_index < strlen (block->joined_text)) {
CharRange *range = g_slice_new0 (CharRange);
CharRange *range = g_new0 (CharRange, 1);
gchar *c = block->joined_text + start_index;
while (*c != '\0' && *c != '\n')
++c;
@ -1647,7 +1647,7 @@ gst_ttml_render_get_line_char_ranges (GstTtmlRender * render,
end_index = gst_ttml_render_get_nearest_breakpoint (block, end_index);
if (end_index > range->first_index) {
new_range = g_slice_new0 (CharRange);
new_range = g_new0 (CharRange, 1);
new_range->first_index = end_index + 1;
new_range->last_index = range->last_index;
GST_CAT_LOG (ttmlrender_debug,
@ -2279,7 +2279,7 @@ gst_ttml_render_rendered_image_new (GstBuffer * image, gint x, gint y,
{
GstTtmlRenderRenderedImage *ret;
ret = g_slice_new0 (GstTtmlRenderRenderedImage);
ret = g_new0 (GstTtmlRenderRenderedImage, 1);
ret->image = image;
ret->x = x;
@ -2301,7 +2301,7 @@ gst_ttml_render_rendered_image_new_empty (void)
static inline GstTtmlRenderRenderedImage *
gst_ttml_render_rendered_image_copy (GstTtmlRenderRenderedImage * image)
{
GstTtmlRenderRenderedImage *ret = g_slice_new0 (GstTtmlRenderRenderedImage);
GstTtmlRenderRenderedImage *ret = g_new0 (GstTtmlRenderRenderedImage, 1);
ret->image = gst_buffer_ref (image->image);
ret->x = image->x;
@ -2319,7 +2319,7 @@ gst_ttml_render_rendered_image_free (GstTtmlRenderRenderedImage * image)
if (!image)
return;
gst_buffer_unref (image->image);
g_slice_free (GstTtmlRenderRenderedImage, image);
g_free (image);
}
@ -2343,7 +2343,7 @@ gst_ttml_render_rendered_image_combine (GstTtmlRenderRenderedImage * image1,
if (image2 && !image1)
return gst_ttml_render_rendered_image_copy (image2);
ret = g_slice_new0 (GstTtmlRenderRenderedImage);
ret = g_new0 (GstTtmlRenderRenderedImage, 1);
/* Work out dimensions of combined image. */
ret->x = MIN (image1->x, image2->x);
@ -2429,7 +2429,7 @@ gst_ttml_render_rendered_image_crop (GstTtmlRenderRenderedImage * image,
return NULL;
}
ret = g_slice_new0 (GstTtmlRenderRenderedImage);
ret = g_new0 (GstTtmlRenderRenderedImage, 1);
ret->x = MAX (image->x, x);
ret->y = MAX (image->y, y);

View file

@ -44,7 +44,7 @@ _gst_subtitle_style_set_free (GstSubtitleStyleSet * style_set)
{
g_return_if_fail (style_set != NULL);
g_free (style_set->font_family);
g_slice_free (GstSubtitleStyleSet, style_set);
g_free (style_set);
}
GST_DEFINE_MINI_OBJECT_TYPE (GstSubtitleStyleSet, gst_subtitle_style_set);
@ -59,7 +59,7 @@ GST_DEFINE_MINI_OBJECT_TYPE (GstSubtitleStyleSet, gst_subtitle_style_set);
GstSubtitleStyleSet *
gst_subtitle_style_set_new (void)
{
GstSubtitleStyleSet *ret = g_slice_new0 (GstSubtitleStyleSet);
GstSubtitleStyleSet *ret = g_new0 (GstSubtitleStyleSet, 1);
GstSubtitleColor white = { 255, 255, 255, 255 };
GstSubtitleColor transparent = { 0, 0, 0, 0 };
@ -88,7 +88,7 @@ _gst_subtitle_element_free (GstSubtitleElement * element)
{
g_return_if_fail (element != NULL);
gst_subtitle_style_set_unref (element->style_set);
g_slice_free (GstSubtitleElement, element);
g_free (element);
}
GST_DEFINE_MINI_OBJECT_TYPE (GstSubtitleElement, gst_subtitle_element);
@ -113,7 +113,7 @@ gst_subtitle_element_new (GstSubtitleStyleSet * style_set,
g_return_val_if_fail (style_set != NULL, NULL);
element = g_slice_new0 (GstSubtitleElement);
element = g_new0 (GstSubtitleElement, 1);
gst_mini_object_init (GST_MINI_OBJECT_CAST (element), 0,
gst_subtitle_element_get_type (), NULL, NULL,
(GstMiniObjectFreeFunction) _gst_subtitle_element_free);
@ -131,7 +131,7 @@ _gst_subtitle_block_free (GstSubtitleBlock * block)
g_return_if_fail (block != NULL);
gst_subtitle_style_set_unref (block->style_set);
g_ptr_array_unref (block->elements);
g_slice_free (GstSubtitleBlock, block);
g_free (block);
}
GST_DEFINE_MINI_OBJECT_TYPE (GstSubtitleBlock, gst_subtitle_block);
@ -154,7 +154,7 @@ gst_subtitle_block_new (GstSubtitleStyleSet * style_set)
g_return_val_if_fail (style_set != NULL, NULL);
block = g_slice_new0 (GstSubtitleBlock);
block = g_new0 (GstSubtitleBlock, 1);
gst_mini_object_init (GST_MINI_OBJECT_CAST (block), 0,
gst_subtitle_block_get_type (), NULL, NULL,
(GstMiniObjectFreeFunction) _gst_subtitle_block_free);
@ -227,7 +227,7 @@ _gst_subtitle_region_free (GstSubtitleRegion * region)
g_return_if_fail (region != NULL);
gst_subtitle_style_set_unref (region->style_set);
g_ptr_array_unref (region->blocks);
g_slice_free (GstSubtitleRegion, region);
g_free (region);
}
GST_DEFINE_MINI_OBJECT_TYPE (GstSubtitleRegion, gst_subtitle_region);
@ -250,7 +250,7 @@ gst_subtitle_region_new (GstSubtitleStyleSet * style_set)
g_return_val_if_fail (style_set != NULL, NULL);
region = g_slice_new0 (GstSubtitleRegion);
region = g_new0 (GstSubtitleRegion, 1);
gst_mini_object_init (GST_MINI_OBJECT_CAST (region), 0,
gst_subtitle_region_get_type (), NULL, NULL,
(GstMiniObjectFreeFunction) _gst_subtitle_region_free);

View file

@ -111,7 +111,7 @@ struct _TtmlStyleSet
static TtmlStyleSet *
ttml_style_set_new (void)
{
TtmlStyleSet *ret = g_slice_new0 (TtmlStyleSet);
TtmlStyleSet *ret = g_new0 (TtmlStyleSet, 1);
ret->table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
return ret;
}
@ -122,7 +122,7 @@ ttml_style_set_delete (TtmlStyleSet * style_set)
{
if (style_set) {
g_hash_table_unref (style_set->table);
g_slice_free (TtmlStyleSet, style_set);
g_free (style_set);
}
}
@ -254,7 +254,7 @@ ttml_delete_element (TtmlElement * element)
g_free ((gpointer) element->region);
ttml_style_set_delete (element->style_set);
g_free ((gpointer) element->text);
g_slice_free (TtmlElement, element);
g_free (element);
}
@ -355,7 +355,7 @@ ttml_parse_element (const xmlNode * node)
return NULL;
}
element = g_slice_new0 (TtmlElement);
element = g_new0 (TtmlElement, 1);
element->type = type;
if ((value = ttml_get_xml_property (node, "id"))) {
@ -1257,7 +1257,7 @@ ttml_create_scenes (GList * region_trees)
"transition", g_list_length (active_trees));
if (active_trees) {
cur_scene = g_slice_new0 (TtmlScene);
cur_scene = g_new0 (TtmlScene, 1);
cur_scene->begin = timestamp;
cur_scene->trees = active_trees;
} else {
@ -1439,7 +1439,7 @@ ttml_remove_nodes_by_region (GNode * node, const gchar * region)
static TtmlElement *
ttml_copy_element (const TtmlElement * element)
{
TtmlElement *ret = g_slice_new0 (TtmlElement);
TtmlElement *ret = g_new0 (TtmlElement, 1);
ret->type = element->type;
if (element->id)
@ -1765,7 +1765,7 @@ ttml_delete_scene (TtmlScene * scene)
g_list_free_full (scene->trees, (GDestroyNotify) ttml_delete_tree);
if (scene->buf)
gst_buffer_unref (scene->buf);
g_slice_free (TtmlScene, scene);
g_free (scene);
}