From c2bc818706df56022c8bb922df2b741cb120f7e4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 27 Oct 2013 23:36:35 +0100 Subject: [PATCH] Work with old and new glib Avoids "deprecated" warnings. --- src/test-buffer-serialize.cc | 7 +++++-- src/test-size-params.cc | 7 +++++-- src/test-would-substitute.cc | 7 +++++-- src/test.cc | 7 +++++-- util/options.cc | 4 ++-- util/options.hh | 4 ++++ util/view-cairo.hh | 4 ++++ 7 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/test-buffer-serialize.cc b/src/test-buffer-serialize.cc index 2287b9406..18c46e952 100644 --- a/src/test-buffer-serialize.cc +++ b/src/test-buffer-serialize.cc @@ -34,7 +34,10 @@ #endif #ifdef HAVE_GLIB -#include +# include +# if !GLIB_CHECK_VERSION (2, 22, 0) +# define g_mapped_file_unref g_mapped_file_free +# endif #endif #include #include @@ -61,7 +64,7 @@ main (int argc, char **argv) GMappedFile *mf = g_mapped_file_new (argv[1], false, NULL); font_data = g_mapped_file_get_contents (mf); len = g_mapped_file_get_length (mf); - destroy = (hb_destroy_func_t) g_mapped_file_free; + destroy = (hb_destroy_func_t) g_mapped_file_unref; user_data = (void *) mf; mm = HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE; #else diff --git a/src/test-size-params.cc b/src/test-size-params.cc index 7463599a1..35d9e3c8e 100644 --- a/src/test-size-params.cc +++ b/src/test-size-params.cc @@ -32,7 +32,10 @@ #include "hb-ot.h" #ifdef HAVE_GLIB -#include +# include +# if !GLIB_CHECK_VERSION (2, 22, 0) +# define g_mapped_file_unref g_mapped_file_free +# endif #endif #include #include @@ -59,7 +62,7 @@ main (int argc, char **argv) GMappedFile *mf = g_mapped_file_new (argv[1], false, NULL); font_data = g_mapped_file_get_contents (mf); len = g_mapped_file_get_length (mf); - destroy = (hb_destroy_func_t) g_mapped_file_free; + destroy = (hb_destroy_func_t) g_mapped_file_unref; user_data = (void *) mf; mm = HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE; #else diff --git a/src/test-would-substitute.cc b/src/test-would-substitute.cc index 6864c223e..8ea87cdf3 100644 --- a/src/test-would-substitute.cc +++ b/src/test-would-substitute.cc @@ -32,7 +32,10 @@ #include "hb-ot.h" #ifdef HAVE_GLIB -#include +# include +# if !GLIB_CHECK_VERSION (2, 22, 0) +# define g_mapped_file_unref g_mapped_file_free +# endif #endif #include #include @@ -63,7 +66,7 @@ main (int argc, char **argv) GMappedFile *mf = g_mapped_file_new (argv[1], false, NULL); font_data = g_mapped_file_get_contents (mf); len = g_mapped_file_get_length (mf); - destroy = (hb_destroy_func_t) g_mapped_file_free; + destroy = (hb_destroy_func_t) g_mapped_file_unref; user_data = (void *) mf; mm = HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE; #else diff --git a/src/test.cc b/src/test.cc index 0546fb766..a8fe046f3 100644 --- a/src/test.cc +++ b/src/test.cc @@ -31,7 +31,10 @@ #include "hb.h" #ifdef HAVE_GLIB -#include +# include +# if !GLIB_CHECK_VERSION (2, 22, 0) +# define g_mapped_file_unref g_mapped_file_free +# endif #endif #include #include @@ -62,7 +65,7 @@ main (int argc, char **argv) GMappedFile *mf = g_mapped_file_new (argv[1], false, NULL); font_data = g_mapped_file_get_contents (mf); len = g_mapped_file_get_length (mf); - destroy = (hb_destroy_func_t) g_mapped_file_free; + destroy = (hb_destroy_func_t) g_mapped_file_unref; user_data = (void *) mf; mm = HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE; #else diff --git a/util/options.cc b/util/options.cc index aa969a69f..66b5e151c 100644 --- a/util/options.cc +++ b/util/options.cc @@ -436,11 +436,11 @@ font_options_t::get_font (void) const font_data = g_mapped_file_get_contents (mf); len = g_mapped_file_get_length (mf); if (len) { - destroy = (hb_destroy_func_t) g_mapped_file_free; + destroy = (hb_destroy_func_t) g_mapped_file_unref; user_data = (void *) mf; mm = HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE; } else - g_mapped_file_free (mf); + g_mapped_file_unref (mf); } else { fail (false, "%s", error->message); //g_error_free (error); diff --git a/util/options.hh b/util/options.hh index 075bf8c8f..e32f9c98d 100644 --- a/util/options.hh +++ b/util/options.hh @@ -54,6 +54,10 @@ #include #include +#if !GLIB_CHECK_VERSION (2, 22, 0) +# define g_mapped_file_unref g_mapped_file_free +#endif + #undef MIN template static inline Type MIN (const Type &a, const Type &b) { return a < b ? a : b; } diff --git a/util/view-cairo.hh b/util/view-cairo.hh index 96a44ff3d..2c504c1b4 100644 --- a/util/view-cairo.hh +++ b/util/view-cairo.hh @@ -81,7 +81,11 @@ struct view_cairo_t helper_cairo_line_t &line = g_array_index (lines, helper_cairo_line_t, i); line.finish (); } +#if GLIB_CHECK_VERSION (2, 22, 0) + g_array_unref (lines); +#else g_array_free (lines, TRUE); +#endif } protected: