Work with old and new glib
Avoids "deprecated" warnings.
This commit is contained in:
parent
46a863d91d
commit
c2bc818706
@ -34,7 +34,10 @@
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GLIB
|
||||
#include <glib.h>
|
||||
# include <glib.h>
|
||||
# if !GLIB_CHECK_VERSION (2, 22, 0)
|
||||
# define g_mapped_file_unref g_mapped_file_free
|
||||
# endif
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@ -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
|
||||
|
@ -32,7 +32,10 @@
|
||||
#include "hb-ot.h"
|
||||
|
||||
#ifdef HAVE_GLIB
|
||||
#include <glib.h>
|
||||
# include <glib.h>
|
||||
# if !GLIB_CHECK_VERSION (2, 22, 0)
|
||||
# define g_mapped_file_unref g_mapped_file_free
|
||||
# endif
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@ -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
|
||||
|
@ -32,7 +32,10 @@
|
||||
#include "hb-ot.h"
|
||||
|
||||
#ifdef HAVE_GLIB
|
||||
#include <glib.h>
|
||||
# include <glib.h>
|
||||
# if !GLIB_CHECK_VERSION (2, 22, 0)
|
||||
# define g_mapped_file_unref g_mapped_file_free
|
||||
# endif
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@ -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
|
||||
|
@ -31,7 +31,10 @@
|
||||
#include "hb.h"
|
||||
|
||||
#ifdef HAVE_GLIB
|
||||
#include <glib.h>
|
||||
# include <glib.h>
|
||||
# if !GLIB_CHECK_VERSION (2, 22, 0)
|
||||
# define g_mapped_file_unref g_mapped_file_free
|
||||
# endif
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@ -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
|
||||
|
@ -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);
|
||||
|
@ -54,6 +54,10 @@
|
||||
#include <glib.h>
|
||||
#include <glib/gprintf.h>
|
||||
|
||||
#if !GLIB_CHECK_VERSION (2, 22, 0)
|
||||
# define g_mapped_file_unref g_mapped_file_free
|
||||
#endif
|
||||
|
||||
#undef MIN
|
||||
template <typename Type> static inline Type MIN (const Type &a, const Type &b) { return a < b ? a : b; }
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user