mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-28 20:05:38 +00:00
metadata: don't check for NULL when calling g_free.
g_free does the check already. Also small code logic cleanup and whitespace fix.
This commit is contained in:
parent
1370d1f3d6
commit
d882207cc2
6 changed files with 25 additions and 39 deletions
|
@ -526,8 +526,6 @@ gst_base_metadata_reset_streaming (GstBaseMetadata * filter)
|
|||
static void
|
||||
gst_base_metadata_reset_parsing (GstBaseMetadata * filter)
|
||||
{
|
||||
|
||||
|
||||
if (filter->prepend_buffer) {
|
||||
gst_buffer_unref (filter->prepend_buffer);
|
||||
filter->prepend_buffer = NULL;
|
||||
|
@ -1991,18 +1989,13 @@ void gst_base_metadata_update_inject_segment_with_new_data
|
|||
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;
|
||||
|
|
|
@ -394,12 +394,12 @@ gst_metadata_mux_create_chunks_from_tags (GstBaseMetadata * base)
|
|||
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");
|
||||
|
@ -407,6 +407,9 @@ gst_metadata_mux_create_chunks_from_tags (GstBaseMetadata * base)
|
|||
&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) {
|
||||
|
@ -414,6 +417,9 @@ gst_metadata_mux_create_chunks_from_tags (GstBaseMetadata * base)
|
|||
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) {
|
||||
|
@ -421,18 +427,13 @@ gst_metadata_mux_create_chunks_from_tags (GstBaseMetadata * base)
|
|||
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
|
||||
|
|
|
@ -388,10 +388,9 @@ metadatamux_exif_create_chunk_from_tag_list (guint8 ** buf, guint32 * size,
|
|||
|
||||
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);
|
||||
|
|
|
@ -252,10 +252,9 @@ metadatamux_iptc_create_chunk_from_tag_list (guint8 ** buf, guint32 * size,
|
|||
|
||||
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);
|
||||
|
|
|
@ -99,10 +99,8 @@ metadata_chunk_array_free (MetadataChunkArray * array)
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -121,9 +119,7 @@ metadata_chunk_array_clear (MetadataChunkArray * array)
|
|||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,8 +235,7 @@ metadata_chunk_array_remove_by_index (MetadataChunkArray * array, guint32 i)
|
|||
{
|
||||
|
||||
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));
|
||||
|
|
|
@ -362,10 +362,9 @@ metadatamux_xmp_create_chunk_from_tag_list (guint8 ** buf, guint32 * size,
|
|||
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue