g_free does the check already. Also small code logic cleanup and whitespace fix.
static void
gst_base_metadata_reset_parsing (GstBaseMetadata * filter)
{
-
-
if (filter->prepend_buffer) {
gst_buffer_unref (filter->prepend_buffer);
filter->prepend_buffer = NULL;
MetadataChunk *inject = META_DATA_INJECT_CHUNKS (base->metadata).chunk;
const gsize inject_len = META_DATA_INJECT_CHUNKS (base->metadata).len;
- if (!(data && size))
- goto done;
- if (*data == 0)
- goto done;
- if (*size == 0)
+ if (!(data && size && *data && *size))
goto done;
for (i = 0; i < inject_len; ++i) {
if (inject[i].type == type) {
inject[i].size = *size;
- if (inject[i].data)
- g_free (inject[i].data);
+ g_free (inject[i].data);
inject[i].data = *data;
*size = 0;
*data = 0;
GstMetadataMux *filter = GST_METADATA_MUX (base);
GstTagSetter *setter = GST_TAG_SETTER (filter);
const GstTagList *taglist = gst_tag_setter_get_tag_list (setter);
- guint8 *buf = NULL;
- guint32 size = 0;
GST_DEBUG_OBJECT (base, "Creating chunks from tags..");
if (taglist) {
+ guint8 *buf = NULL;
+ guint32 size = 0;
if (gst_base_metadata_get_option_flag (base) & META_OPT_EXIF) {
GST_DEBUG_OBJECT (base, "Using EXIF");
&filter->exif_options);
gst_base_metadata_update_inject_segment_with_new_data (base, &buf, &size,
MD_CHUNK_EXIF);
+ g_free (buf);
+ buf = NULL;
+ size = 0;
}
if (gst_base_metadata_get_option_flag (base) & META_OPT_IPTC) {
metadatamux_iptc_create_chunk_from_tag_list (&buf, &size, taglist);
gst_base_metadata_update_inject_segment_with_new_data (base, &buf, &size,
MD_CHUNK_IPTC);
+ g_free (buf);
+ buf = NULL;
+ size = 0;
}
if (gst_base_metadata_get_option_flag (base) & META_OPT_XMP) {
metadatamux_xmp_create_chunk_from_tag_list (&buf, &size, taglist);
gst_base_metadata_update_inject_segment_with_new_data (base, &buf, &size,
MD_CHUNK_XMP);
+ g_free (buf);
}
- }
-
- else {
+ } else {
GST_DEBUG_OBJECT (base, "Empty taglist");
}
- if (buf) {
- g_free (buf);
- }
-
}
static gboolean
if (!(buf && size))
goto done;
- if (*buf) {
- g_free (*buf);
- *buf = NULL;
- }
+
+ g_free (*buf);
+ *buf = NULL;
*size = 0;
val = gst_tag_list_get_value_index (taglist, GST_TAG_EXIF, 0);
if (!(buf && size))
goto done;
- if (*buf) {
- g_free (*buf);
- *buf = NULL;
- }
+
+ g_free (*buf);
+ *buf = NULL;
*size = 0;
val = gst_tag_list_get_value_index (taglist, GST_TAG_IPTC, 0);
{
metadata_chunk_array_clear (array);
array->allocated_len = 0;
- if (array->chunk) {
- g_free (array->chunk);
- array->chunk = NULL;
- }
+ g_free (array->chunk);
+ array->chunk = NULL;
}
/*
{
while (array->len) {
array->len--;
- if (array->chunk[array->len].data) {
- g_free (array->chunk[array->len].data);
- }
+ g_free (array->chunk[array->len].data);
}
}
{
if (i < array->len) {
- if (array->chunk[i].data)
- g_free (array->chunk[i].data);
+ g_free (array->chunk[i].data);
if (i < --array->len) {
memmove (&array->chunk[i], &array->chunk[i + 1],
sizeof (MetadataChunk) * (array->len - i));
if (!(buf && size))
goto done;
- if (*buf) {
- g_free (*buf);
- *buf = NULL;
- }
+
+ g_free (*buf);
+ *buf = NULL;
*size = 0;
val = gst_tag_list_get_value_index (taglist, GST_TAG_XMP, 0);