From: Thijs Vermeir Date: Mon, 21 Jul 2008 23:02:40 +0000 (+0000) Subject: gst/gstcaps.c: Allow passing of NULL to gst_caps_union X-Git-Tag: RELEASE-0_10_21~95 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6f1ab1797478f59a8e64ce08480b8ca0eb417123;p=platform%2Fupstream%2Fgstreamer.git gst/gstcaps.c: Allow passing of NULL to gst_caps_union Original commit message from CVS: * gst/gstcaps.c: Allow passing of NULL to gst_caps_union --- diff --git a/ChangeLog b/ChangeLog index 9becebd..65d81cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-07-22 Thijs Vermeir + + * gst/gstcaps.c: + Allow passing of NULL to gst_caps_union + 2008-07-21 Thijs Vermeir * gst/gstghostpad.c: diff --git a/gst/gstcaps.c b/gst/gstcaps.c index 19ba104..6d4ba77 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -1406,6 +1406,8 @@ gst_caps_subtract (const GstCaps * minuend, const GstCaps * subtrahend) * Creates a new #GstCaps that contains all the formats that are in * either @caps1 and @caps2. * + * This function deals correctly with passing NULL for any of the caps. + * * Returns: the new #GstCaps */ GstCaps * @@ -1414,6 +1416,15 @@ gst_caps_union (const GstCaps * caps1, const GstCaps * caps2) GstCaps *dest1; GstCaps *dest2; + if (!caps1 && !caps2) + return gst_caps_new_empty (); + + if (!caps1 || gst_caps_is_empty (caps1)) + return gst_caps_copy (caps2); + + if (!caps2 || gst_caps_is_empty (caps2)) + return gst_caps_copy (caps1); + if (gst_caps_is_any (caps1) || gst_caps_is_any (caps2)) return gst_caps_new_any ();