* src/profiler.c: Delete.
[bpt/emacs.git] / src / ftfont.c
index 3849897..bea1e01 100644 (file)
@@ -87,8 +87,6 @@ static Lisp_Object ftfont_lookup_cache (Lisp_Object,
 
 static void ftfont_filter_properties (Lisp_Object font, Lisp_Object alist);
 
-Lisp_Object ftfont_font_format (FcPattern *, Lisp_Object);
-
 #define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM))
 
 static struct
@@ -655,7 +653,7 @@ struct OpenTypeSpec
 static struct OpenTypeSpec *
 ftfont_get_open_type_spec (Lisp_Object otf_spec)
 {
-  struct OpenTypeSpec *spec = malloc (sizeof *spec);
+  struct OpenTypeSpec *spec = xmalloc_unsafe (sizeof *spec);
   Lisp_Object val;
   int i, j;
   bool negative;
@@ -695,12 +693,12 @@ ftfont_get_open_type_spec (Lisp_Object otf_spec)
       spec->features[i] =
        (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) < XINT (len)
         ? 0
-        : malloc (XINT (len) * sizeof *spec->features[i]));
+        : xmalloc_atomic_unsafe (XINT (len) * sizeof *spec->features[i]));
       if (! spec->features[i])
        {
          if (i > 0 && spec->features[0])
-           free (spec->features[0]);
-         free (spec);
+           xfree (spec->features[0]);
+         xfree (spec);
          return NULL;
        }
       for (j = 0, negative = 0; CONSP (val); val = XCDR (val))
@@ -870,10 +868,10 @@ ftfont_spec_pattern (Lisp_Object spec, char *otlayout, struct OpenTypeSpec **ots
   if (*otspec)
     {
       if ((*otspec)->nfeatures[0] > 0)
-       free ((*otspec)->features[0]);
+       xfree ((*otspec)->features[0]);
       if ((*otspec)->nfeatures[1] > 0)
-       free ((*otspec)->features[1]);
-      free (*otspec);
+       xfree ((*otspec)->features[1]);
+      xfree (*otspec);
       *otspec = NULL;
     }
 
@@ -1011,6 +1009,7 @@ ftfont_list (struct frame *f, Lisp_Object spec)
       if (otspec)
        {
          FcChar8 *file;
+         bool passed;
          OTF *otf;
 
          if (FcPatternGetString (fontset->fonts[i], FC_FILE, 0, &file)
@@ -1019,14 +1018,16 @@ ftfont_list (struct frame *f, Lisp_Object spec)
          otf = OTF_open ((char *) file);
          if (! otf)
            continue;
-         if (OTF_check_features (otf, 1,
-                                 otspec->script_tag, otspec->langsys_tag,
-                                 otspec->features[0],
-                                 otspec->nfeatures[0]) != 1
-             || OTF_check_features (otf, 0,
-                                    otspec->script_tag, otspec->langsys_tag,
-                                    otspec->features[1],
-                                    otspec->nfeatures[1]) != 1)
+         passed = (OTF_check_features (otf, 1, otspec->script_tag,
+                                       otspec->langsys_tag,
+                                       otspec->features[0],
+                                       otspec->nfeatures[0]) == 1
+                   && OTF_check_features (otf, 0, otspec->script_tag,
+                                          otspec->langsys_tag,
+                                          otspec->features[1],
+                                          otspec->nfeatures[1]) == 1);
+         OTF_close (otf);
+         if (!passed)
            continue;
        }
 #endif /* HAVE_LIBOTF */