Skip to content
Snippets Groups Projects
Commit 461a8620 authored by Marc-André Lureau's avatar Marc-André Lureau
Browse files

glib-compat: add g_test_add_data_func_full fallback


Move the fallback from qtest_add_data_func_full() to glib-compat.

Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
parent e703dcba
No related branches found
No related tags found
No related merge requests found
......@@ -328,4 +328,25 @@ static inline void g_source_set_name_by_id(guint tag, const char *name)
#define g_test_subprocess() (0)
#endif
#if !GLIB_CHECK_VERSION(2, 34, 0)
static inline void
g_test_add_data_func_full(const char *path,
gpointer data,
gpointer fn,
gpointer data_free_func)
{
#if GLIB_CHECK_VERSION(2, 26, 0)
/* back-compat casts, remove this once we can require new-enough glib */
g_test_add_vtable(path, 0, data, NULL,
(GTestFixtureFunc)fn, (GTestFixtureFunc) data_free_func);
#else
/* back-compat casts, remove this once we can require new-enough glib */
g_test_add_vtable(path, 0, data, NULL,
(void (*)(void)) fn, (void (*)(void)) data_free_func);
#endif
}
#endif
#endif
......@@ -805,17 +805,7 @@ void qtest_add_data_func_full(const char *str, void *data,
GDestroyNotify data_free_func)
{
gchar *path = g_strdup_printf("/%s/%s", qtest_get_arch(), str);
#if GLIB_CHECK_VERSION(2, 34, 0)
g_test_add_data_func_full(path, data, fn, data_free_func);
#elif GLIB_CHECK_VERSION(2, 26, 0)
/* back-compat casts, remove this once we can require new-enough glib */
g_test_add_vtable(path, 0, data, NULL,
(GTestFixtureFunc)fn, (GTestFixtureFunc) data_free_func);
#else
/* back-compat casts, remove this once we can require new-enough glib */
g_test_add_vtable(path, 0, data, NULL,
(void (*)(void)) fn, (void (*)(void)) data_free_func);
#endif
g_free(path);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment