Use g_memdup2() where available and add fallback for older GLib versions
authorTim-Philipp Müller <tim@centricular.com>
Sat, 22 May 2021 17:41:08 +0000 (18:41 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 2 Jun 2021 12:40:31 +0000 (12:40 +0000)
Size is constant here, so no problem in any case, but g_memdup() is
now deprecated and we don't want deprecation warnings.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/257>

ges/ges-pitivi-formatter.c
meson.build

index 47cef55..5bc6b8d 100644 (file)
@@ -476,7 +476,7 @@ make_source (GESFormatter * self, GList * reflist, GHashTable * source_table)
       layer = ges_layer_new ();
       g_object_set (layer, "auto-transition", TRUE, "priority", prio, NULL);
       ges_timeline_add_layer (self->timeline, layer);
-      g_hash_table_insert (priv->layers_table, g_memdup (&prio,
+      g_hash_table_insert (priv->layers_table, g_memdup2 (&prio,
               sizeof (guint64)), layer);
     }
 
index a5df86a..7fdb1a2 100644 (file)
@@ -322,6 +322,10 @@ if gst_version_nano == 0
   endif
 endif
 
+if gio_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")')