Remove unnecessary NULL checks before g_free()

g_free() is NULL-safe
This commit is contained in:
Reynaldo H. Verdejo Pinochet 2015-11-15 02:58:54 -08:00
parent 5f79ccb420
commit 0c95b0a738
5 changed files with 23 additions and 46 deletions

View file

@ -292,17 +292,13 @@ static void
gst_encoding_profile_finalize (GObject * object) gst_encoding_profile_finalize (GObject * object)
{ {
GstEncodingProfile *prof = (GstEncodingProfile *) object; GstEncodingProfile *prof = (GstEncodingProfile *) object;
if (prof->name)
g_free (prof->name); g_free (prof->name);
if (prof->format) if (prof->format)
gst_caps_unref (prof->format); gst_caps_unref (prof->format);
if (prof->preset)
g_free (prof->preset); g_free (prof->preset);
if (prof->description)
g_free (prof->description); g_free (prof->description);
if (prof->restriction) if (prof->restriction)
gst_caps_unref (prof->restriction); gst_caps_unref (prof->restriction);
if (prof->preset_name)
g_free (prof->preset_name); g_free (prof->preset_name);
} }
@ -443,7 +439,6 @@ gst_encoding_profile_get_restriction (GstEncodingProfile * profile)
void void
gst_encoding_profile_set_name (GstEncodingProfile * profile, const gchar * name) gst_encoding_profile_set_name (GstEncodingProfile * profile, const gchar * name)
{ {
if (profile->name)
g_free (profile->name); g_free (profile->name);
profile->name = g_strdup (name); profile->name = g_strdup (name);
} }
@ -460,7 +455,6 @@ void
gst_encoding_profile_set_description (GstEncodingProfile * profile, gst_encoding_profile_set_description (GstEncodingProfile * profile,
const gchar * description) const gchar * description)
{ {
if (profile->description)
g_free (profile->description); g_free (profile->description);
profile->description = g_strdup (description); profile->description = g_strdup (description);
} }
@ -522,7 +516,6 @@ void
gst_encoding_profile_set_preset (GstEncodingProfile * profile, gst_encoding_profile_set_preset (GstEncodingProfile * profile,
const gchar * preset) const gchar * preset)
{ {
if (profile->preset)
g_free (profile->preset); g_free (profile->preset);
profile->preset = g_strdup (preset); profile->preset = g_strdup (preset);
} }
@ -538,7 +531,6 @@ void
gst_encoding_profile_set_preset_name (GstEncodingProfile * profile, gst_encoding_profile_set_preset_name (GstEncodingProfile * profile,
const gchar * preset_name) const gchar * preset_name)
{ {
if (profile->preset_name)
g_free (profile->preset_name); g_free (profile->preset_name);
profile->preset_name = g_strdup (preset_name); profile->preset_name = g_strdup (preset_name);
} }

View file

@ -104,11 +104,8 @@ gst_encoding_target_finalize (GObject * object)
GST_DEBUG ("Finalizing"); GST_DEBUG ("Finalizing");
if (target->name)
g_free (target->name); g_free (target->name);
if (target->category)
g_free (target->category); g_free (target->category);
if (target->description)
g_free (target->description); g_free (target->description);
g_list_foreach (target->profiles, (GFunc) g_object_unref, NULL); g_list_foreach (target->profiles, (GFunc) g_object_unref, NULL);
@ -655,13 +652,9 @@ parse_encoding_profile (GKeyFile * in, gchar * parentprofilename,
if (formatcaps) if (formatcaps)
gst_caps_unref (formatcaps); gst_caps_unref (formatcaps);
if (pname)
g_free (pname); g_free (pname);
if (description)
g_free (description); g_free (description);
if (preset)
g_free (preset); g_free (preset);
if (proftype)
g_free (proftype); g_free (proftype);
return sprof; return sprof;
@ -690,11 +683,8 @@ parse_keyfile (GKeyFile * in, gchar * targetname, gchar * categoryname,
g_strfreev (groups); g_strfreev (groups);
if (targetname)
g_free (targetname); g_free (targetname);
if (categoryname)
g_free (categoryname); g_free (categoryname);
if (description)
g_free (description); g_free (description);
return res; return res;

View file

@ -863,7 +863,6 @@ gst_rtsp_message_take_body (GstRTSPMessage * msg, guint8 * data, guint size)
g_return_val_if_fail (msg != NULL, GST_RTSP_EINVAL); g_return_val_if_fail (msg != NULL, GST_RTSP_EINVAL);
g_return_val_if_fail (data != NULL || size == 0, GST_RTSP_EINVAL); g_return_val_if_fail (data != NULL || size == 0, GST_RTSP_EINVAL);
if (msg->body)
g_free (msg->body); g_free (msg->body);
msg->body = data; msg->body = data;

View file

@ -3016,7 +3016,6 @@ gst_sdp_message_parse_buffer (const guint8 * data, guint size,
#undef SIZE_CHECK_GUARD #undef SIZE_CHECK_GUARD
out: out:
if (buffer)
g_free (buffer); g_free (buffer);
return GST_SDP_OK; return GST_SDP_OK;

View file

@ -55,7 +55,6 @@ list_codecs (void)
desc = gst_pb_utils_get_codec_description (caps); desc = gst_pb_utils_get_codec_description (caps);
g_print (" %s - %s\n", desc, tmpstr); g_print (" %s - %s\n", desc, tmpstr);
g_free (tmpstr); g_free (tmpstr);
if (desc)
g_free (desc); g_free (desc);
gst_caps_remove_structure (caps, 0); gst_caps_remove_structure (caps, 0);
} }
@ -73,7 +72,6 @@ list_codecs (void)
desc = gst_pb_utils_get_codec_description (caps); desc = gst_pb_utils_get_codec_description (caps);
g_print (" %s - %s\n", desc, tmpstr); g_print (" %s - %s\n", desc, tmpstr);
g_free (tmpstr); g_free (tmpstr);
if (desc)
g_free (desc); g_free (desc);
gst_caps_remove_structure (caps, 0); gst_caps_remove_structure (caps, 0);
} }
@ -91,7 +89,6 @@ list_codecs (void)
desc = gst_pb_utils_get_codec_description (caps); desc = gst_pb_utils_get_codec_description (caps);
g_print (" %s - %s\n", desc, tmpstr); g_print (" %s - %s\n", desc, tmpstr);
g_free (tmpstr); g_free (tmpstr);
if (desc)
g_free (desc); g_free (desc);
gst_caps_remove_structure (caps, 0); gst_caps_remove_structure (caps, 0);
} }