Skip to content

Commit

Permalink
Use new g_memdup2 if available.
Browse files Browse the repository at this point in the history
This mostly addresses a deprecation warning. We can get rid of the
ifdefs if we decide to simply bump the required version.
  • Loading branch information
Stefan Sauer committed Feb 11, 2024
1 parent 5de1028 commit 9dd6786
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/gst/audio/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ bt_g_param_spec_clone (GObjectClass * src_class, const gchar * src_name)

g_type_query (G_PARAM_SPEC_TYPE (src), &query);
/* this is pretty lame, we have no idea if we copy e.g. pointer fields */
#if GLIB_CHECK_VERSION(2, 68, 0)
pspec = g_memdup2 (src, (gsize) query.instance_size);
#else
pspec = g_memdup (src, query.instance_size);
#endif
/* reset known fields, see g_param_spec_init() */
pspec->owner_type = 0;
pspec->qdata = NULL;
Expand Down
4 changes: 4 additions & 0 deletions src/lib/core/song-io-native-bzt.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,11 @@ bt_song_io_native_bzt_save (gconstpointer const _self,
gsf_off_t len = gsf_output_size (self->priv->output);
const guint8 *mem = gsf_output_memory_get_bytes (
(GsfOutputMemory *) self->priv->output);
#if GLIB_CHECK_VERSION(2, 68, 0)
gpointer data = g_memdup2 (mem, (gsize) len);
#else
gpointer data = g_memdup (mem, (guint) len);
#endif
g_object_set ((gpointer) self, "data", data, "data-len",
(guint) len, NULL);
}
Expand Down
4 changes: 4 additions & 0 deletions src/lib/core/song-io-native-xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ bt_song_io_native_xml_save (gconstpointer const _self,
gpointer data;

xmlDocDumpMemory (song_doc, &mem, (int *) &len);
#if GLIB_CHECK_VERSION(2, 68, 0)
data = g_memdup2 (mem, len);
#else
data = g_memdup (mem, len);
#endif
xmlFree (mem);
g_object_set ((gpointer) self, "data", data, "data-len", len, NULL);
}
Expand Down
14 changes: 12 additions & 2 deletions src/ui/edit/main-page-patterns.c
Original file line number Diff line number Diff line change
Expand Up @@ -1819,12 +1819,22 @@ pattern_table_refresh (const BtMainPagePatterns * self)
pid, j);
group->num_columns = self->priv->voice_params;
group->columns =
#if GLIB_CHECK_VERSION(2, 68, 0)
g_memdup2 (stamp->columns,
sizeof (BtPatternEditorColumn) * group->num_columns);
#else
g_memdup (stamp->columns,
sizeof (BtPatternEditorColumn) * group->num_columns);
sizeof (BtPatternEditorColumn) * group->num_columns);
#endif
for (i = 0; i < group->num_columns; i++) {
group->columns[i].user_data =
#if GLIB_CHECK_VERSION(2, 68, 0)
g_memdup2 (group->columns[i].user_data,
sizeof (BtPatternEditorColumnConverters));
#else
g_memdup (group->columns[i].user_data,
sizeof (BtPatternEditorColumnConverters));
sizeof (BtPatternEditorColumnConverters));
#endif
}
group->width = 0;
group++;
Expand Down

0 comments on commit 9dd6786

Please sign in to comment.