From 67931bfded47e1b8fe733161b5f30af45dd26dc0 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 12 Mar 2012 12:21:34 +0100 Subject: [PATCH] caps: make _normalize take ownership of input Make gst_caps_normalize() take ownership of the input so that it can more intelligently decide when to copy or not. --- gst/gstcaps.c | 10 ++++++---- tests/check/gst/gstcaps.c | 3 --- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/gst/gstcaps.c b/gst/gstcaps.c index f4964d01cd..a51f1130b2 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -1616,13 +1616,15 @@ gst_caps_normalize_foreach (GQuark field_id, const GValue * value, gpointer ptr) /** * gst_caps_normalize: - * @caps: a #GstCaps to normalize + * @caps: (transfer full): a #GstCaps to normalize * - * Creates a new #GstCaps that represents the same set of formats as + * Returns a #GstCaps that represents the same set of formats as * @caps, but contains no lists. Each list is expanded into separate * @GstStructures. * - * Returns: the new #GstCaps + * This function takes ownership of @caps. + * + * Returns: (transfer full): the normalized #GstCaps */ GstCaps * gst_caps_normalize (GstCaps * caps) @@ -1633,7 +1635,7 @@ gst_caps_normalize (GstCaps * caps) g_return_val_if_fail (GST_IS_CAPS (caps), NULL); - newcaps = _gst_caps_copy (caps); + newcaps = gst_caps_make_writable (caps); nf.caps = newcaps; for (i = 0; i < gst_caps_get_size (newcaps); i++) { diff --git a/tests/check/gst/gstcaps.c b/tests/check/gst/gstcaps.c index 1e3255563d..a0090a2a97 100644 --- a/tests/check/gst/gstcaps.c +++ b/tests/check/gst/gstcaps.c @@ -839,7 +839,6 @@ GST_START_TEST (test_normalize) fail_unless (gst_structure_foreach (st, _caps_is_fixed_foreach, NULL)); } - gst_caps_unref (in); gst_caps_unref (out); gst_caps_unref (norm); @@ -858,7 +857,6 @@ GST_START_TEST (test_normalize) fail_unless (gst_structure_foreach (st, _caps_is_fixed_foreach, NULL)); } - gst_caps_unref (in); gst_caps_unref (out); gst_caps_unref (norm); @@ -876,7 +874,6 @@ GST_START_TEST (test_normalize) fail_unless (gst_structure_foreach (st, _caps_is_fixed_foreach, NULL)); } - gst_caps_unref (in); gst_caps_unref (out); gst_caps_unref (norm); }