mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-16 19:25:18 +00:00
Use g_memdup2() where available and add fallback for older GLib versions
g_memdup() is deprecated since GLib 2.68 and we want to avoid deprecation warnings with recent versions of GLib. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2280>
This commit is contained in:
parent
7433870528
commit
a561b1bd86
26 changed files with 46 additions and 36 deletions
|
@ -1092,7 +1092,7 @@ gst_curl_base_sink_debug_cb (CURL * handle, curl_infotype type, char *data,
|
|||
case CURLINFO_TEXT:
|
||||
case CURLINFO_HEADER_IN:
|
||||
case CURLINFO_HEADER_OUT:
|
||||
msg = g_memdup (data, size);
|
||||
msg = g_memdup2 (data, size);
|
||||
if (size > 0) {
|
||||
msg[size - 1] = '\0';
|
||||
g_strchomp (msg);
|
||||
|
|
|
@ -2127,7 +2127,7 @@ gst_curl_http_src_get_debug (CURL * handle, curl_infotype type, char *data,
|
|||
switch (type) {
|
||||
case CURLINFO_TEXT:
|
||||
case CURLINFO_HEADER_OUT:
|
||||
msg = g_memdup (data, size);
|
||||
msg = g_memdup2 (data, size);
|
||||
if (size > 0) {
|
||||
msg[size - 1] = '\0';
|
||||
g_strchomp (msg);
|
||||
|
|
|
@ -451,7 +451,7 @@ gst_faad_update_caps (GstFaad * faad, faacDecFrameInfo * info)
|
|||
faad->samplerate = info->samplerate;
|
||||
faad->channels = info->channels;
|
||||
g_free (faad->channel_positions);
|
||||
faad->channel_positions = g_memdup (info->channel_position, faad->channels);
|
||||
faad->channel_positions = g_memdup2 (info->channel_position, faad->channels);
|
||||
|
||||
faad->bps = 16 / 8;
|
||||
|
||||
|
|
|
@ -1280,7 +1280,7 @@ gst_hls_demux_update_fragment_info (GstAdaptiveDemuxStream * stream)
|
|||
g_free (hlsdemux_stream->current_key);
|
||||
hlsdemux_stream->current_key = g_strdup (file->key);
|
||||
g_free (hlsdemux_stream->current_iv);
|
||||
hlsdemux_stream->current_iv = g_memdup (file->iv, sizeof (file->iv));
|
||||
hlsdemux_stream->current_iv = g_memdup2 (file->iv, sizeof (file->iv));
|
||||
|
||||
g_free (stream->fragment.uri);
|
||||
stream->fragment.uri = g_strdup (file->uri);
|
||||
|
|
|
@ -540,7 +540,7 @@ gst_teletextdec_process_telx_buffer (GstTeletextDec * teletext, GstBuffer * buf)
|
|||
n_lines = teletext->frame->current_slice - teletext->frame->sliced_begin;
|
||||
GST_LOG_OBJECT (teletext, "Completed frame, decoding new %d lines",
|
||||
n_lines);
|
||||
s = g_memdup (teletext->frame->sliced_begin,
|
||||
s = g_memdup2 (teletext->frame->sliced_begin,
|
||||
n_lines * sizeof (vbi_sliced));
|
||||
vbi_decode (teletext->decoder, s, n_lines, teletext->last_ts);
|
||||
/* From vbi_decode():
|
||||
|
|
|
@ -271,7 +271,7 @@ gst_h264_pps_copy (GstH264PPS * dst_pps, const GstH264PPS * src_pps)
|
|||
*dst_pps = *src_pps;
|
||||
|
||||
if (src_pps->slice_group_id)
|
||||
dst_pps->slice_group_id = g_memdup (src_pps->slice_group_id,
|
||||
dst_pps->slice_group_id = g_memdup2 (src_pps->slice_group_id,
|
||||
src_pps->pic_size_in_map_units_minus1 + 1);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -204,7 +204,7 @@ gst_mpegts_descriptor_parse_dvb_stuffing (const GstMpegtsDescriptor *
|
|||
|
||||
data = (guint8 *) descriptor->data + 2;
|
||||
|
||||
*stuffing_bytes = g_memdup (data, descriptor->length);
|
||||
*stuffing_bytes = g_memdup2 (data, descriptor->length);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -600,7 +600,7 @@ _gst_mpegts_dvb_linkage_descriptor_copy (GstMpegtsDVBLinkageDescriptor * source)
|
|||
break;
|
||||
}
|
||||
|
||||
copy->private_data_bytes = g_memdup (source->private_data_bytes,
|
||||
copy->private_data_bytes = g_memdup2 (source->private_data_bytes,
|
||||
source->private_data_length);
|
||||
|
||||
return copy;
|
||||
|
@ -825,7 +825,7 @@ gst_mpegts_descriptor_parse_dvb_linkage (const GstMpegtsDescriptor * descriptor,
|
|||
}
|
||||
|
||||
res->private_data_length = end - data;
|
||||
res->private_data_bytes = g_memdup (data, res->private_data_length);
|
||||
res->private_data_bytes = g_memdup2 (data, res->private_data_length);
|
||||
|
||||
*desc = res;
|
||||
|
||||
|
@ -2013,7 +2013,7 @@ gst_mpegts_descriptor_parse_dvb_private_data_specifier (const
|
|||
if (length && private_data) {
|
||||
*length = descriptor->length - 4;
|
||||
|
||||
*private_data = g_memdup (data + 4, *length);
|
||||
*private_data = g_memdup2 (data + 4, *length);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -2091,7 +2091,7 @@ _gst_mpegts_dvb_data_broadcast_descriptor_copy (GstMpegtsDataBroadcastDescriptor
|
|||
|
||||
copy = g_slice_dup (GstMpegtsDataBroadcastDescriptor, source);
|
||||
|
||||
copy->selector_bytes = g_memdup (source->selector_bytes, source->length);
|
||||
copy->selector_bytes = g_memdup2 (source->selector_bytes, source->length);
|
||||
copy->language_code = g_strdup (source->language_code);
|
||||
copy->text = g_strdup (source->text);
|
||||
|
||||
|
@ -2145,7 +2145,7 @@ gst_mpegts_descriptor_parse_dvb_data_broadcast (const GstMpegtsDescriptor
|
|||
res->length = *data;
|
||||
data += 1;
|
||||
|
||||
res->selector_bytes = g_memdup (data, res->length);
|
||||
res->selector_bytes = g_memdup2 (data, res->length);
|
||||
data += res->length;
|
||||
|
||||
res->language_code = convert_lang_code (data);
|
||||
|
@ -2220,7 +2220,7 @@ gst_mpegts_descriptor_parse_dvb_data_broadcast_id (const GstMpegtsDescriptor
|
|||
|
||||
*len = descriptor->length - 2;
|
||||
|
||||
*id_selector_bytes = g_memdup (data, *len);
|
||||
*id_selector_bytes = g_memdup2 (data, *len);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -700,7 +700,7 @@ _copy_descriptor (GstMpegtsDescriptor * desc)
|
|||
GstMpegtsDescriptor *copy;
|
||||
|
||||
copy = g_slice_dup (GstMpegtsDescriptor, desc);
|
||||
copy->data = g_memdup (desc->data, desc->length + 2);
|
||||
copy->data = g_memdup2 (desc->data, desc->length + 2);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
@ -788,7 +788,7 @@ gst_mpegts_parse_descriptors (guint8 * buffer, gsize buf_len)
|
|||
desc->tag = *data++;
|
||||
desc->length = *data++;
|
||||
/* Copy the data now that we known the size */
|
||||
desc->data = g_memdup (desc->data, desc->length + 2);
|
||||
desc->data = g_memdup2 (desc->data, desc->length + 2);
|
||||
GST_LOG ("descriptor 0x%02x length:%d", desc->tag, desc->length);
|
||||
GST_MEMDUMP ("descriptor", desc->data + 2, desc->length);
|
||||
/* extended descriptors */
|
||||
|
|
|
@ -233,7 +233,7 @@ _gst_mpegts_section_copy (GstMpegtsSection * section)
|
|||
copy->last_section_number = section->last_section_number;
|
||||
copy->crc = section->crc;
|
||||
|
||||
copy->data = g_memdup (section->data, section->section_length);
|
||||
copy->data = g_memdup2 (section->data, section->section_length);
|
||||
copy->section_length = section->section_length;
|
||||
/* Note: We do not copy the cached parsed item, it will be
|
||||
* reconstructed on that copy */
|
||||
|
|
|
@ -188,7 +188,7 @@ gst_spectra_scope_render (GstAudioVisualizer * bscope, GstBuffer * audio,
|
|||
|
||||
channels = GST_AUDIO_INFO_CHANNELS (&bscope->ainfo);
|
||||
|
||||
mono_adata = (gint16 *) g_memdup (amap.data, amap.size);
|
||||
mono_adata = g_memdup2 (amap.data, amap.size);
|
||||
|
||||
if (channels > 1) {
|
||||
guint ch = channels;
|
||||
|
|
|
@ -673,7 +673,7 @@ new_packet_cb (guint8 * data, guint len, void *user_data)
|
|||
|
||||
GST_LOG_OBJECT (mux, "Outputting a packet of length %d", len);
|
||||
|
||||
data = g_memdup (data, len);
|
||||
data = g_memdup2 (data, len);
|
||||
buf = gst_buffer_new_wrapped (data, len);
|
||||
|
||||
GST_BUFFER_TIMESTAMP (buf) = mux->last_ts;
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1113,7 +1116,7 @@ section_start:
|
|||
/* Only do fast-path if we have enough byte */
|
||||
if (data + section_length <= packet->data_end) {
|
||||
if ((section =
|
||||
gst_mpegts_section_new (packet->pid, g_memdup (data,
|
||||
gst_mpegts_section_new (packet->pid, g_memdup2 (data,
|
||||
section_length), section_length))) {
|
||||
GST_DEBUG ("PID 0x%04x Short section complete !", packet->pid);
|
||||
section->offset = packet->offset;
|
||||
|
|
|
@ -825,7 +825,7 @@ scan_keyframe_h264 (TSDemuxStream * stream, const guint8 * data,
|
|||
" we will push later");
|
||||
|
||||
h264infos->framedata.data =
|
||||
g_memdup (frame_unit.data + frame_unit.sc_offset,
|
||||
g_memdup2 (frame_unit.data + frame_unit.sc_offset,
|
||||
stream->current_size - frame_unit.sc_offset);
|
||||
h264infos->framedata.size = stream->current_size - frame_unit.sc_offset;
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ mxf_metadata_wave_audio_essence_descriptor_handle_tag (MXFMetadataBase *
|
|||
mxf_timestamp_to_string (&self->peak_envelope_timestamp, str));
|
||||
break;
|
||||
case 0x3d31:
|
||||
self->peak_envelope_data = g_memdup (tag_data, tag_size);
|
||||
self->peak_envelope_data = g_memdup2 (tag_data, tag_size);
|
||||
self->peak_envelope_data_length = tag_size;
|
||||
GST_DEBUG (" peak evelope data size = %u",
|
||||
self->peak_envelope_data_length);
|
||||
|
@ -507,7 +507,7 @@ mxf_metadata_wave_audio_essence_descriptor_write_tags (MXFMetadataBase * m,
|
|||
t = g_slice_new0 (MXFLocalTag);
|
||||
memcpy (&t->ul, &peak_envelope_data_ul, 16);
|
||||
t->size = self->peak_envelope_data_length;
|
||||
t->data = g_memdup (self->peak_envelope_data, t->size);
|
||||
t->data = g_memdup2 (self->peak_envelope_data, t->size);
|
||||
mxf_primer_pack_add_mapping (primer, 0x3d31, &t->ul);
|
||||
ret = g_list_prepend (ret, t);
|
||||
}
|
||||
|
|
|
@ -1656,7 +1656,7 @@ mxf_dms1_identification_handle_tag (MXFMetadataBase * metadata,
|
|||
memcpy (self->identifier_kind, tag_data, tag_size);
|
||||
GST_DEBUG (" identifier kind = %s", self->identifier_kind);
|
||||
} else if (memcmp (tag_ul, &identifier_value_ul, 16) == 0) {
|
||||
self->identifier_value = g_memdup (tag_data, tag_size);
|
||||
self->identifier_value = g_memdup2 (tag_data, tag_size);
|
||||
self->identifier_value_length = tag_size;
|
||||
GST_DEBUG (" identifier value length = %u", tag_size);
|
||||
} else if (memcmp (tag_ul, &identification_locator_ul, 16) == 0) {
|
||||
|
|
|
@ -252,7 +252,7 @@ mxf_metadata_base_to_buffer (MXFMetadataBase * self, MXFPrimerPack * primer)
|
|||
mxf_primer_pack_add_mapping (primer, 0x0000, &t->ul);
|
||||
memcpy (tmp->data, t->data, t->size);
|
||||
} else {
|
||||
tmp->data = g_memdup (t->data, t->size);
|
||||
tmp->data = g_memdup2 (t->data, t->size);
|
||||
}
|
||||
tags = g_list_prepend (tags, tmp);
|
||||
}
|
||||
|
|
|
@ -1321,7 +1321,7 @@ mxf_mpeg_video_get_descriptor (GstPadTemplate * tmpl, GstCaps * caps,
|
|||
codec_data = gst_value_get_buffer (v);
|
||||
gst_buffer_map ((GstBuffer *) codec_data, &map, GST_MAP_READ);
|
||||
t->size = map.size;
|
||||
t->data = g_memdup (map.data, map.size);
|
||||
t->data = g_memdup2 (map.data, map.size);
|
||||
gst_buffer_unmap ((GstBuffer *) codec_data, &map);
|
||||
memcpy (&t->ul, &sony_mpeg4_extradata, 16);
|
||||
mxf_local_tag_insert (t, &MXF_METADATA_BASE (ret)->other_tags);
|
||||
|
|
|
@ -1706,7 +1706,7 @@ mxf_local_tag_add_to_hash_table (const MXFPrimerPack * primer,
|
|||
local_tag = g_slice_new0 (MXFLocalTag);
|
||||
memcpy (&local_tag->ul, ul, sizeof (MXFUL));
|
||||
local_tag->size = tag_size;
|
||||
local_tag->data = tag_size == 0 ? NULL : g_memdup (tag_data, tag_size);
|
||||
local_tag->data = tag_size == 0 ? NULL : g_memdup2 (tag_data, tag_size);
|
||||
local_tag->g_slice = FALSE;
|
||||
|
||||
g_hash_table_insert (*hash_table, &local_tag->ul, local_tag);
|
||||
|
|
|
@ -329,7 +329,7 @@ gst_amf_node_get_string (const GstAmfNode * node, gsize * out_size)
|
|||
|
||||
if (out_size) {
|
||||
*out_size = size;
|
||||
return g_memdup (data, size);
|
||||
return g_memdup2 (data, size);
|
||||
} else {
|
||||
return g_strndup (data, size);
|
||||
}
|
||||
|
@ -444,9 +444,9 @@ gst_amf_node_set_string (GstAmfNode * node, const gchar * value, gssize size)
|
|||
|
||||
if (size < 0) {
|
||||
size = strlen (value);
|
||||
copy = g_memdup (value, size + 1);
|
||||
copy = g_memdup2 (value, size + 1);
|
||||
} else {
|
||||
copy = g_memdup (value, size);
|
||||
copy = g_memdup2 (value, size);
|
||||
}
|
||||
|
||||
gst_amf_node_take_string (node, copy, size);
|
||||
|
|
|
@ -537,6 +537,10 @@ if gst_version_nano == 0
|
|||
endif
|
||||
endif
|
||||
|
||||
if glib_dep.version().version_compare('< 2.67.4')
|
||||
cdata.set('g_memdup2(ptr,sz)', '(G_LIKELY(((guint64)(sz)) < G_MAXUINT)) ? g_memdup(ptr,sz) : (g_abort(),NULL)')
|
||||
endif
|
||||
|
||||
configure_file(output : 'config.h', configuration : cdata)
|
||||
|
||||
run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')
|
||||
|
|
|
@ -914,7 +914,7 @@ gst_amc_audio_dec_set_format (GstAudioDecoder * decoder, GstCaps * caps)
|
|||
guint8 *data;
|
||||
|
||||
gst_buffer_map (codec_data, &minfo, GST_MAP_READ);
|
||||
data = g_memdup (minfo.data, minfo.size);
|
||||
data = g_memdup2 (minfo.data, minfo.size);
|
||||
self->codec_datas = g_list_prepend (self->codec_datas, data);
|
||||
gst_amc_format_set_buffer (format, "csd-0", data, minfo.size, &err);
|
||||
if (err)
|
||||
|
@ -946,7 +946,7 @@ gst_amc_audio_dec_set_format (GstAudioDecoder * decoder, GstCaps * caps)
|
|||
|
||||
fname = g_strdup_printf ("csd-%d", j);
|
||||
gst_buffer_map (buf, &minfo, GST_MAP_READ);
|
||||
data = g_memdup (minfo.data, minfo.size);
|
||||
data = g_memdup2 (minfo.data, minfo.size);
|
||||
self->codec_datas = g_list_prepend (self->codec_datas, data);
|
||||
gst_amc_format_set_buffer (format, fname, data, minfo.size, &err);
|
||||
if (err)
|
||||
|
|
|
@ -1811,7 +1811,7 @@ gst_amc_video_dec_set_format (GstVideoDecoder * decoder,
|
|||
GstMapInfo cminfo;
|
||||
|
||||
gst_buffer_map (state->codec_data, &cminfo, GST_MAP_READ);
|
||||
codec_data = g_memdup (cminfo.data, cminfo.size);
|
||||
codec_data = g_memdup2 (cminfo.data, cminfo.size);
|
||||
codec_data_size = cminfo.size;
|
||||
|
||||
is_format_change |= (!self->codec_data
|
||||
|
|
|
@ -438,7 +438,7 @@ gint *gst_amc_codec_capabilities_handle_get_color_formats
|
|||
goto done;
|
||||
}
|
||||
|
||||
ret = g_memdup (elems, sizeof (jint) * len);
|
||||
ret = g_memdup2 (elems, sizeof (jint) * len);
|
||||
*length = len;
|
||||
|
||||
done:
|
||||
|
|
|
@ -475,7 +475,7 @@ gst_amc_format_get_buffer (GstAmcFormat * format, const gchar * key,
|
|||
gst_amc_buffer_get_position_and_limit (&buf, NULL, &position, &limit);
|
||||
*size = limit;
|
||||
|
||||
*data = g_memdup (*data + position, limit);
|
||||
*data = g_memdup2 (*data + position, limit);
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@ gst_amc_format_get_buffer (GstAmcFormat * format, const gchar * key,
|
|||
}
|
||||
|
||||
*size = buffer.length;
|
||||
*data = (guint8 *) g_memdup (buffer.ptr, buffer.length);
|
||||
*data = (guint8 *) g_memdup2 (buffer.ptr, buffer.length);
|
||||
MLMediaFormatKeyByteBufferRelease (format->handle, &buffer);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gst/check/gstcheck.h>
|
||||
#include <gst/mpegts/mpegts.h>
|
||||
|
@ -509,7 +512,7 @@ GST_START_TEST (test_mpegts_atsc_stt)
|
|||
guint8 *data;
|
||||
GstDateTime *dt;
|
||||
|
||||
data = g_memdup (stt_data_check, 20);
|
||||
data = g_memdup2 (stt_data_check, 20);
|
||||
|
||||
section = gst_mpegts_section_new (0x1ffb, data, 20);
|
||||
stt = gst_mpegts_section_get_atsc_stt (section);
|
||||
|
|
Loading…
Reference in a new issue