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,18 +292,14 @@ static void
gst_encoding_profile_finalize (GObject * object)
{
GstEncodingProfile *prof = (GstEncodingProfile *) object;
if (prof->name)
g_free (prof->name);
g_free (prof->name);
if (prof->format)
gst_caps_unref (prof->format);
if (prof->preset)
g_free (prof->preset);
if (prof->description)
g_free (prof->description);
g_free (prof->preset);
g_free (prof->description);
if (prof->restriction)
gst_caps_unref (prof->restriction);
if (prof->preset_name)
g_free (prof->preset_name);
g_free (prof->preset_name);
}
static void
@ -443,8 +439,7 @@ gst_encoding_profile_get_restriction (GstEncodingProfile * profile)
void
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);
}
@ -460,8 +455,7 @@ void
gst_encoding_profile_set_description (GstEncodingProfile * profile,
const gchar * description)
{
if (profile->description)
g_free (profile->description);
g_free (profile->description);
profile->description = g_strdup (description);
}
@ -522,8 +516,7 @@ void
gst_encoding_profile_set_preset (GstEncodingProfile * profile,
const gchar * preset)
{
if (profile->preset)
g_free (profile->preset);
g_free (profile->preset);
profile->preset = g_strdup (preset);
}
@ -538,8 +531,7 @@ void
gst_encoding_profile_set_preset_name (GstEncodingProfile * profile,
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);
}

View file

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

View file

@ -863,8 +863,7 @@ 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 (data != NULL || size == 0, GST_RTSP_EINVAL);
if (msg->body)
g_free (msg->body);
g_free (msg->body);
msg->body = data;
msg->body_size = size;

View file

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

View file

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