[HarfBuzz] harfbuzz-ng: Branch 'master' - 8 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue May 10 14:48:46 PDT 2011


 TODO                        |    4 
 configure.ac                |    3 
 src/hb-blob.cc              |  218 +++++++++++---------------------
 src/hb-blob.h               |   22 +--
 src/hb-common.cc            |    1 
 src/hb-font.cc              |    2 
 src/hb-mutex-private.hh     |    4 
 src/hb-open-type-private.hh |   32 +++-
 src/hb-ot-layout.cc         |    7 -
 test/Makefile.am            |    1 
 test/test-blob.c            |  298 ++++++++++++++++++++++++++++++++++++++++++++
 test/test-buffer.c          |  149 +++++++++++-----------
 test/test-object.c          |    2 
 13 files changed, 500 insertions(+), 243 deletions(-)

New commits:
commit f82c18630471216a04e4e3ad42396da4e6d74cba
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue May 10 17:48:34 2011 -0400

    [test/blob] Fix bug in test

diff --git a/test/test-blob.c b/test/test-blob.c
index 91c1170..22d40b7 100644
--- a/test/test-blob.c
+++ b/test/test-blob.c
@@ -157,7 +157,8 @@ fixture_init (fixture_t *fixture, gconstpointer user_data)
       break;
 
     case HB_MEMORY_MODE_WRITABLE:
-      data = strndup (test_data, sizeof (test_data));
+      data = malloc (sizeof (test_data));
+      memcpy ((char *) data, test_data, sizeof (test_data));
       len = sizeof (test_data);
       free_func = (hb_destroy_func_t) free_up_free;
       break;
commit 785d23acd0ce72d399f9c5021bebc854872648af
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue May 10 17:41:44 2011 -0400

    [test/blob] Add create_sub_blob()

diff --git a/test/test-blob.c b/test/test-blob.c
index 03962fb..91c1170 100644
--- a/test/test-blob.c
+++ b/test/test-blob.c
@@ -254,6 +254,22 @@ test_blob (fixture_t *fixture, gconstpointer user_data)
     g_assert ('\0' == data[i]);
 }
 
+static void
+test_blob_subblob (fixture_t *fixture, gconstpointer user_data)
+{
+  hb_blob_t *b = fixture->blob;
+
+  fixture->len -= 2;
+  fixture->data++;
+  fixture->blob = hb_blob_create_sub_blob (b, 1, fixture->len);
+  hb_blob_destroy (b);
+
+  test_blob (fixture, user_data);
+
+  fixture->data--;
+  fixture->len += 2;
+}
+
 
 int
 main (int argc, char **argv)
@@ -270,6 +286,7 @@ main (int argc, char **argv)
     const char *blob_name = blob_names[i];
 
     hb_test_add_fixture_flavor (fixture, blob_type, blob_name, test_blob);
+    hb_test_add_fixture_flavor (fixture, blob_type, blob_name, test_blob_subblob);
   }
 
   /*
commit 0617b1558234673d3924f37541be01b04d36f05a
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue May 10 17:37:08 2011 -0400

    [test] Test blob API

diff --git a/test/Makefile.am b/test/Makefile.am
index c744795..cc4519c 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -12,6 +12,7 @@ check_PROGRAMS = $(TEST_PROGS)
 noinst_PROGRAMS = $(TEST_PROGS)
 
 TEST_PROGS += \
+	test-blob \
 	test-buffer \
 	test-common \
 	test-object \
diff --git a/test/test-blob.c b/test/test-blob.c
new file mode 100644
index 0000000..03962fb
--- /dev/null
+++ b/test/test-blob.c
@@ -0,0 +1,280 @@
+/*
+ * Copyright © 2011  Google, Inc.
+ *
+ *  This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Google Author(s): Behdad Esfahbod
+ */
+
+#include "hb-test.h"
+
+/* Unit tests for hb-blob.h */
+
+#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MPROTECT)
+
+# define TEST_MMAP 1
+
+#ifdef HAVE_SYS_MMAN_H
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+#include <sys/mman.h>
+#endif /* HAVE_SYS_MMAN_H */
+
+#endif
+
+
+static void
+test_blob_empty (void)
+{
+  hb_blob_t *blob;
+  unsigned int len;
+  const char *data;
+  char *data_writable;
+
+  g_assert (hb_blob_is_immutable (hb_blob_get_empty ()));
+  g_assert (hb_blob_get_empty () != NULL);
+
+  blob = hb_blob_get_empty ();
+  g_assert (blob == hb_blob_get_empty ());
+
+  len = hb_blob_get_length (blob);
+  g_assert_cmpint (len, ==, 0);
+
+  data = hb_blob_get_data (blob, NULL);
+  g_assert (data == NULL);
+
+  data = hb_blob_get_data (blob, &len);
+  g_assert (data == NULL);
+  g_assert_cmpint (len, ==, 0);
+
+  data_writable = hb_blob_get_data_writable (blob, NULL);
+  g_assert (data == NULL);
+
+  data_writable = hb_blob_get_data_writable (blob, &len);
+  g_assert (data_writable == NULL);
+  g_assert_cmpint (len, ==, 0);
+}
+
+static const char test_data[] = "test\0data";
+
+static const char *blob_names[] = {
+  "duplicate",
+  "readonly",
+  "writable"
+#ifdef TEST_MMAP
+   , "readonly-may-make-writable"
+#endif
+};
+
+typedef struct
+{
+  hb_blob_t *blob;
+  int freed;
+  char *data;
+  unsigned int len;
+} fixture_t;
+
+static void
+free_up (fixture_t *fixture)
+{
+  g_assert_cmpint (fixture->freed, ==, 0);
+  fixture->freed++;
+}
+
+static void
+free_up_free (fixture_t *fixture)
+{
+  free_up (fixture);
+  free (fixture->data);
+}
+
+
+static uintptr_t
+get_pagesize (void)
+{
+  uintptr_t pagesize = -1;
+
+#if defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE)
+  pagesize = (uintptr_t) sysconf (_SC_PAGE_SIZE);
+#elif defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
+  pagesize = (uintptr_t) sysconf (_SC_PAGESIZE);
+#elif defined(HAVE_GETPAGESIZE)
+  pagesize = (uintptr_t) getpagesize ();
+#endif
+
+  g_assert (pagesize != (uintptr_t) -1);
+
+  return pagesize;
+}
+
+static void
+free_up_munmap (fixture_t *fixture)
+{
+  free_up (fixture);
+  munmap (fixture->data, get_pagesize ());
+}
+
+#include <errno.h>
+static void
+fixture_init (fixture_t *fixture, gconstpointer user_data)
+{
+  hb_memory_mode_t mm = (hb_memory_mode_t) GPOINTER_TO_INT (user_data);
+  unsigned int len;
+  const char *data;
+  hb_destroy_func_t free_func;
+
+  switch (GPOINTER_TO_INT (user_data))
+  {
+    case HB_MEMORY_MODE_DUPLICATE:
+      data = test_data;
+      len = sizeof (test_data);
+      free_func = (hb_destroy_func_t) free_up;
+      break;
+
+    case HB_MEMORY_MODE_READONLY:
+      data = test_data;
+      len = sizeof (test_data);
+      free_func = (hb_destroy_func_t) free_up;
+      break;
+
+    case HB_MEMORY_MODE_WRITABLE:
+      data = strndup (test_data, sizeof (test_data));
+      len = sizeof (test_data);
+      free_func = (hb_destroy_func_t) free_up_free;
+      break;
+
+#if TEST_MMAP
+    case HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE:
+    {
+      uintptr_t pagesize = get_pagesize ();
+
+      data = mmap (NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+      g_assert (data != (char *) -1);
+      memcpy ((char *) data, test_data, sizeof (test_data));
+      mprotect ((char *) data, pagesize, PROT_READ);
+      len = sizeof (test_data);
+      free_func = (hb_destroy_func_t) free_up_munmap;
+      break;
+    }
+#endif
+
+    default:
+      g_assert_not_reached ();
+  }
+
+  fixture->freed = 0;
+  fixture->data = (char *) data;
+  fixture->len = len;
+  fixture->blob = hb_blob_create (data, len, mm, fixture, free_func);
+}
+
+static void
+fixture_finish (fixture_t *fixture, gconstpointer user_data)
+{
+  hb_blob_destroy (fixture->blob);
+  g_assert_cmpint (fixture->freed, ==, 1);
+}
+
+
+static void
+test_blob (fixture_t *fixture, gconstpointer user_data)
+{
+  hb_blob_t *b = fixture->blob;
+  hb_memory_mode_t mm = GPOINTER_TO_INT (user_data);
+  unsigned int len;
+  const char *data;
+  char *data_writable;
+  unsigned int i;
+
+  g_assert (b);
+
+  len = hb_blob_get_length (b);
+  g_assert_cmpint (len, ==, fixture->len);
+
+  data = hb_blob_get_data (b, &len);
+  g_assert_cmpint (len, ==, fixture->len);
+  if (mm == HB_MEMORY_MODE_DUPLICATE) {
+    g_assert (data != fixture->data);
+    g_assert_cmpint (fixture->freed, ==, 1);
+    mm = HB_MEMORY_MODE_WRITABLE;
+  } else {
+    g_assert (data == fixture->data);
+    g_assert_cmpint (fixture->freed, ==, 0);
+  }
+
+  data_writable = hb_blob_get_data_writable (b, &len);
+  g_assert_cmpint (len, ==, fixture->len);
+  g_assert (data_writable);
+  g_assert (0 == memcmp (data_writable, fixture->data, fixture->len));
+  if (mm == HB_MEMORY_MODE_READONLY) {
+    g_assert (data_writable != data);
+    g_assert_cmpint (fixture->freed, ==, 1);
+  } else {
+    g_assert (data_writable == data);
+  }
+
+  data = hb_blob_get_data (b, &len);
+  g_assert_cmpint (len, ==, fixture->len);
+  g_assert (data == data_writable);
+
+  memset (data_writable, 0, fixture->len);
+
+  /* Now, make it immutable and watch get_data_writable() fail */
+
+  g_assert (!hb_blob_is_immutable (b));
+  hb_blob_make_immutable (b);
+  g_assert (hb_blob_is_immutable (b));
+
+  data_writable = hb_blob_get_data_writable (b, &len);
+  g_assert (!data_writable);
+  g_assert_cmpint (len, ==, 0);
+
+  data = hb_blob_get_data (b, &len);
+  g_assert_cmpint (len, ==, fixture->len);
+  for (i = 0; i < len; i++)
+    g_assert ('\0' == data[i]);
+}
+
+
+int
+main (int argc, char **argv)
+{
+  unsigned int i;
+
+  hb_test_init (&argc, &argv);
+
+  hb_test_add (test_blob_empty);
+
+  for (i = 0; i < G_N_ELEMENTS (blob_names); i++)
+  {
+    const void *blob_type = GINT_TO_POINTER (i);
+    const char *blob_name = blob_names[i];
+
+    hb_test_add_fixture_flavor (fixture, blob_type, blob_name, test_blob);
+  }
+
+  /*
+   * create_sub_blob
+   */
+
+  return hb_test_run ();
+}
diff --git a/test/test-buffer.c b/test/test-buffer.c
index 3f0eb56..2b1c7b7 100644
--- a/test/test-buffer.c
+++ b/test/test-buffer.c
@@ -53,35 +53,37 @@ static const char *buffer_names[] = {
 
 typedef struct
 {
-  hb_buffer_t *b;
+  hb_buffer_t *buffer;
 } fixture_t;
 
 static void
 fixture_init (fixture_t *fixture, gconstpointer user_data)
 {
+  hb_buffer_t *b;
   unsigned int i;
 
-  fixture->b = hb_buffer_create (0);
+  b = fixture->buffer = hb_buffer_create (0);
 
-  switch (GPOINTER_TO_INT (user_data)) {
+  switch (GPOINTER_TO_INT (user_data))
+  {
     case BUFFER_EMPTY:
       break;
 
     case BUFFER_ONE_BY_ONE:
       for (i = 1; i < G_N_ELEMENTS (utf32) - 1; i++)
-	hb_buffer_add (fixture->b, utf32[i], 1, i);
+	hb_buffer_add (b, utf32[i], 1, i);
       break;
 
     case BUFFER_UTF32:
-      hb_buffer_add_utf32 (fixture->b, utf32, G_N_ELEMENTS (utf32), 1, G_N_ELEMENTS (utf32) - 2);
+      hb_buffer_add_utf32 (b, utf32, G_N_ELEMENTS (utf32), 1, G_N_ELEMENTS (utf32) - 2);
       break;
 
     case BUFFER_UTF16:
-      hb_buffer_add_utf16 (fixture->b, utf16, G_N_ELEMENTS (utf16), 1, G_N_ELEMENTS (utf16) - 2);
+      hb_buffer_add_utf16 (b, utf16, G_N_ELEMENTS (utf16), 1, G_N_ELEMENTS (utf16) - 2);
       break;
 
     case BUFFER_UTF8:
-      hb_buffer_add_utf8  (fixture->b, utf8,  G_N_ELEMENTS (utf8),  1, G_N_ELEMENTS (utf8)  - 2);
+      hb_buffer_add_utf8  (b, utf8,  G_N_ELEMENTS (utf8),  1, G_N_ELEMENTS (utf8)  - 2);
       break;
 
     default:
@@ -92,64 +94,66 @@ fixture_init (fixture_t *fixture, gconstpointer user_data)
 static void
 fixture_finish (fixture_t *fixture, gconstpointer user_data)
 {
-  hb_buffer_destroy (fixture->b);
+  hb_buffer_destroy (fixture->buffer);
 }
 
 
 static void
 test_buffer_properties (fixture_t *fixture, gconstpointer user_data)
 {
+  hb_buffer_t *b = fixture->buffer;
   hb_unicode_funcs_t *ufuncs;
 
   /* test default properties */
 
-  g_assert (hb_buffer_get_unicode_funcs (fixture->b) == hb_unicode_funcs_get_default ());
-  g_assert (hb_buffer_get_direction (fixture->b) == HB_DIRECTION_INVALID);
-  g_assert (hb_buffer_get_script (fixture->b) == HB_SCRIPT_INVALID);
-  g_assert (hb_buffer_get_language (fixture->b) == NULL);
+  g_assert (hb_buffer_get_unicode_funcs (b) == hb_unicode_funcs_get_default ());
+  g_assert (hb_buffer_get_direction (b) == HB_DIRECTION_INVALID);
+  g_assert (hb_buffer_get_script (b) == HB_SCRIPT_INVALID);
+  g_assert (hb_buffer_get_language (b) == NULL);
 
 
   /* test property changes are retained */
   ufuncs = hb_unicode_funcs_create (NULL);
-  hb_buffer_set_unicode_funcs (fixture->b, ufuncs);
+  hb_buffer_set_unicode_funcs (b, ufuncs);
   hb_unicode_funcs_destroy (ufuncs);
-  g_assert (hb_buffer_get_unicode_funcs (fixture->b) == ufuncs);
+  g_assert (hb_buffer_get_unicode_funcs (b) == ufuncs);
 
-  hb_buffer_set_direction (fixture->b, HB_DIRECTION_RTL);
-  g_assert (hb_buffer_get_direction (fixture->b) == HB_DIRECTION_RTL);
+  hb_buffer_set_direction (b, HB_DIRECTION_RTL);
+  g_assert (hb_buffer_get_direction (b) == HB_DIRECTION_RTL);
 
-  hb_buffer_set_script (fixture->b, HB_SCRIPT_ARABIC);
-  g_assert (hb_buffer_get_script (fixture->b) == HB_SCRIPT_ARABIC);
+  hb_buffer_set_script (b, HB_SCRIPT_ARABIC);
+  g_assert (hb_buffer_get_script (b) == HB_SCRIPT_ARABIC);
 
-  hb_buffer_set_language (fixture->b, hb_language_from_string ("fa"));
-  g_assert (hb_buffer_get_language (fixture->b) == hb_language_from_string ("Fa"));
+  hb_buffer_set_language (b, hb_language_from_string ("fa"));
+  g_assert (hb_buffer_get_language (b) == hb_language_from_string ("Fa"));
 
 
   /* test reset clears properties */
 
-  hb_buffer_reset (fixture->b);
+  hb_buffer_reset (b);
 
-  g_assert (hb_buffer_get_unicode_funcs (fixture->b) == hb_unicode_funcs_get_default ());
-  g_assert (hb_buffer_get_direction (fixture->b) == HB_DIRECTION_INVALID);
-  g_assert (hb_buffer_get_script (fixture->b) == HB_SCRIPT_INVALID);
-  g_assert (hb_buffer_get_language (fixture->b) == NULL);
+  g_assert (hb_buffer_get_unicode_funcs (b) == hb_unicode_funcs_get_default ());
+  g_assert (hb_buffer_get_direction (b) == HB_DIRECTION_INVALID);
+  g_assert (hb_buffer_get_script (b) == HB_SCRIPT_INVALID);
+  g_assert (hb_buffer_get_language (b) == NULL);
 }
 
 static void
 test_buffer_contents (fixture_t *fixture, gconstpointer user_data)
 {
+  hb_buffer_t *b = fixture->buffer;
   unsigned int i, len, len2;
   buffer_type_t buffer_type = GPOINTER_TO_INT (user_data);
   hb_glyph_info_t *glyphs;
 
   if (buffer_type == BUFFER_EMPTY) {
-    g_assert_cmpint (hb_buffer_get_length (fixture->b), ==, 0);
+    g_assert_cmpint (hb_buffer_get_length (b), ==, 0);
     return;
   }
 
-  len = hb_buffer_get_length (fixture->b);
-  glyphs = hb_buffer_get_glyph_infos (fixture->b, NULL); /* test NULL */
-  glyphs = hb_buffer_get_glyph_infos (fixture->b, &len2);
+  len = hb_buffer_get_length (b);
+  glyphs = hb_buffer_get_glyph_infos (b, NULL); /* test NULL */
+  glyphs = hb_buffer_get_glyph_infos (b, &len2);
   g_assert_cmpint (len, ==, len2);
   g_assert_cmpint (len, ==, 5);
 
@@ -174,22 +178,22 @@ test_buffer_contents (fixture_t *fixture, gconstpointer user_data)
 
   /* reverse, test, and reverse back */
 
-  hb_buffer_reverse (fixture->b);
+  hb_buffer_reverse (b);
   for (i = 0; i < len; i++)
     g_assert_cmphex (glyphs[i].codepoint, ==, utf32[len-i]);
 
-  hb_buffer_reverse (fixture->b);
+  hb_buffer_reverse (b);
   for (i = 0; i < len; i++)
     g_assert_cmphex (glyphs[i].codepoint, ==, utf32[1+i]);
 
   /* reverse_clusters works same as reverse for now since each codepoint is
    * in its own cluster */
 
-  hb_buffer_reverse_clusters (fixture->b);
+  hb_buffer_reverse_clusters (b);
   for (i = 0; i < len; i++)
     g_assert_cmphex (glyphs[i].codepoint, ==, utf32[len-i]);
 
-  hb_buffer_reverse_clusters (fixture->b);
+  hb_buffer_reverse_clusters (b);
   for (i = 0; i < len; i++)
     g_assert_cmphex (glyphs[i].codepoint, ==, utf32[1+i]);
 
@@ -198,18 +202,18 @@ test_buffer_contents (fixture_t *fixture, gconstpointer user_data)
 
   /* reverse, test, and reverse back */
 
-  hb_buffer_reverse (fixture->b);
+  hb_buffer_reverse (b);
   for (i = 0; i < len; i++)
     g_assert_cmphex (glyphs[i].codepoint, ==, utf32[len-i]);
 
-  hb_buffer_reverse (fixture->b);
+  hb_buffer_reverse (b);
   for (i = 0; i < len; i++)
     g_assert_cmphex (glyphs[i].codepoint, ==, utf32[1+i]);
 
   /* reverse_clusters twice still should return the original string,
    * but when applied once, the 1-2 cluster should be retained. */
 
-  hb_buffer_reverse_clusters (fixture->b);
+  hb_buffer_reverse_clusters (b);
   for (i = 0; i < len; i++) {
     unsigned int j = len-1-i;
     if (j == 1)
@@ -219,7 +223,7 @@ test_buffer_contents (fixture_t *fixture, gconstpointer user_data)
     g_assert_cmphex (glyphs[i].codepoint, ==, utf32[1+j]);
   }
 
-  hb_buffer_reverse_clusters (fixture->b);
+  hb_buffer_reverse_clusters (b);
   for (i = 0; i < len; i++)
     g_assert_cmphex (glyphs[i].codepoint, ==, utf32[1+i]);
 
@@ -227,40 +231,41 @@ test_buffer_contents (fixture_t *fixture, gconstpointer user_data)
   /* test setting length */
 
   /* enlarge */
-  g_assert (hb_buffer_set_length (fixture->b, 10));
-  glyphs = hb_buffer_get_glyph_infos (fixture->b, NULL);
-  g_assert_cmpint (hb_buffer_get_length (fixture->b), ==, 10);
+  g_assert (hb_buffer_set_length (b, 10));
+  glyphs = hb_buffer_get_glyph_infos (b, NULL);
+  g_assert_cmpint (hb_buffer_get_length (b), ==, 10);
   for (i = 0; i < 5; i++)
     g_assert_cmphex (glyphs[i].codepoint, ==, utf32[1+i]);
   for (i = 5; i < 10; i++)
     g_assert_cmphex (glyphs[i].codepoint, ==, 0);
   /* shrink */
-  g_assert (hb_buffer_set_length (fixture->b, 3));
-  glyphs = hb_buffer_get_glyph_infos (fixture->b, NULL);
-  g_assert_cmpint (hb_buffer_get_length (fixture->b), ==, 3);
+  g_assert (hb_buffer_set_length (b, 3));
+  glyphs = hb_buffer_get_glyph_infos (b, NULL);
+  g_assert_cmpint (hb_buffer_get_length (b), ==, 3);
   for (i = 0; i < 3; i++)
     g_assert_cmphex (glyphs[i].codepoint, ==, utf32[1+i]);
 
 
-  g_assert (hb_buffer_allocation_successful (fixture->b));
+  g_assert (hb_buffer_allocation_successful (b));
 
 
   /* test reset clears content */
 
-  hb_buffer_reset (fixture->b);
-  g_assert_cmpint (hb_buffer_get_length (fixture->b), ==, 0);
+  hb_buffer_reset (b);
+  g_assert_cmpint (hb_buffer_get_length (b), ==, 0);
 }
 
 static void
 test_buffer_positions (fixture_t *fixture, gconstpointer user_data)
 {
+  hb_buffer_t *b = fixture->buffer;
   unsigned int i, len, len2;
   hb_glyph_position_t *positions;
 
   /* Without shaping, positions should all be zero */
-  len = hb_buffer_get_length (fixture->b);
-  positions = hb_buffer_get_glyph_positions (fixture->b, NULL); /* test NULL */
-  positions = hb_buffer_get_glyph_positions (fixture->b, &len2);
+  len = hb_buffer_get_length (b);
+  positions = hb_buffer_get_glyph_positions (b, NULL); /* test NULL */
+  positions = hb_buffer_get_glyph_positions (b, &len2);
   g_assert_cmpint (len, ==, len2);
   for (i = 0; i < len; i++) {
     g_assert_cmpint (0, ==, positions[i].x_advance);
@@ -271,49 +276,51 @@ test_buffer_positions (fixture_t *fixture, gconstpointer user_data)
   }
 
   /* test reset clears content */
-  hb_buffer_reset (fixture->b);
-  g_assert_cmpint (hb_buffer_get_length (fixture->b), ==, 0);
+  hb_buffer_reset (b);
+  g_assert_cmpint (hb_buffer_get_length (b), ==, 0);
 }
 
 static void
 test_buffer_allocation (fixture_t *fixture, gconstpointer user_data)
 {
-  g_assert_cmpint (hb_buffer_get_length (fixture->b), ==, 0);
+  hb_buffer_t *b = fixture->buffer;
+
+  g_assert_cmpint (hb_buffer_get_length (b), ==, 0);
 
-  g_assert (hb_buffer_pre_allocate (fixture->b, 100));
-  g_assert_cmpint (hb_buffer_get_length (fixture->b), ==, 0);
-  g_assert (hb_buffer_allocation_successful (fixture->b));
+  g_assert (hb_buffer_pre_allocate (b, 100));
+  g_assert_cmpint (hb_buffer_get_length (b), ==, 0);
+  g_assert (hb_buffer_allocation_successful (b));
 
   /* lets try a huge allocation, make sure it fails */
-  g_assert (!hb_buffer_pre_allocate (fixture->b, (unsigned int) -1));
-  g_assert_cmpint (hb_buffer_get_length (fixture->b), ==, 0);
-  g_assert (!hb_buffer_allocation_successful (fixture->b));
+  g_assert (!hb_buffer_pre_allocate (b, (unsigned int) -1));
+  g_assert_cmpint (hb_buffer_get_length (b), ==, 0);
+  g_assert (!hb_buffer_allocation_successful (b));
 
   /* small one again */
-  g_assert (hb_buffer_pre_allocate (fixture->b, 50));
-  g_assert_cmpint (hb_buffer_get_length (fixture->b), ==, 0);
-  g_assert (!hb_buffer_allocation_successful (fixture->b));
+  g_assert (hb_buffer_pre_allocate (b, 50));
+  g_assert_cmpint (hb_buffer_get_length (b), ==, 0);
+  g_assert (!hb_buffer_allocation_successful (b));
 
-  hb_buffer_reset (fixture->b);
-  g_assert (hb_buffer_allocation_successful (fixture->b));
+  hb_buffer_reset (b);
+  g_assert (hb_buffer_allocation_successful (b));
 
   /* all allocation and size  */
-  g_assert (!hb_buffer_pre_allocate (fixture->b, ((unsigned int) -1) / 20 + 1));
-  g_assert (!hb_buffer_allocation_successful (fixture->b));
+  g_assert (!hb_buffer_pre_allocate (b, ((unsigned int) -1) / 20 + 1));
+  g_assert (!hb_buffer_allocation_successful (b));
 
-  hb_buffer_reset (fixture->b);
-  g_assert (hb_buffer_allocation_successful (fixture->b));
+  hb_buffer_reset (b);
+  g_assert (hb_buffer_allocation_successful (b));
 
   /* technically, this one can actually pass on 64bit machines, but
    * I'm doubtful that any malloc allows 4GB allocations at a time.
    * But let's only enable it on a 32-bit machine. */
   if (sizeof (long) == 4) {
-    g_assert (!hb_buffer_pre_allocate (fixture->b, ((unsigned int) -1) / 20 - 1));
-    g_assert (!hb_buffer_allocation_successful (fixture->b));
+    g_assert (!hb_buffer_pre_allocate (b, ((unsigned int) -1) / 20 - 1));
+    g_assert (!hb_buffer_allocation_successful (b));
   }
 
-  hb_buffer_reset (fixture->b);
-  g_assert (hb_buffer_allocation_successful (fixture->b));
+  hb_buffer_reset (b);
+  g_assert (hb_buffer_allocation_successful (b));
 }
 
 
commit 1c9f8717eb12c37c219333cbb0d123e1d2da4896
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri May 6 22:28:26 2011 -0400

    [API] Simplify blob API, remove lock

diff --git a/TODO b/TODO
index a05900d..298730f 100644
--- a/TODO
+++ b/TODO
@@ -16,8 +16,6 @@ API issues to fix before 1.0:
 
 - Add hb-cairo glue
 
-- Fix blob, remove mutex, etc.
-
 - Add sanitize API
 
 - Add glib GBoxedType stuff
diff --git a/src/hb-blob.cc b/src/hb-blob.cc
index b903acc..cdb7496 100644
--- a/src/hb-blob.cc
+++ b/src/hb-blob.cc
@@ -28,7 +28,6 @@
 
 #include "hb-blob.h"
 #include "hb-object-private.hh"
-#include "hb-mutex-private.hh"
 
 #ifdef HAVE_SYS_MMAN_H
 #ifdef HAVE_UNISTD_H
@@ -51,15 +50,11 @@ HB_BEGIN_DECLS
 struct _hb_blob_t {
   hb_object_header_t header;
 
-  unsigned int length;
-
-  hb_mutex_t lock;
-  /* the rest are protected by lock */
-
-  unsigned int lock_count;
-  hb_memory_mode_t mode;
+  bool immutable;
 
   const char *data;
+  unsigned int length;
+  hb_memory_mode_t mode;
 
   void *user_data;
   hb_destroy_func_t destroy;
@@ -68,19 +63,19 @@ struct _hb_blob_t {
 static hb_blob_t _hb_blob_nil = {
   HB_OBJECT_HEADER_STATIC,
 
-  0, /* length */
-
-  HB_MUTEX_INIT, /* lock */
-
-  0, /* lock_count */
-  HB_MEMORY_MODE_READONLY, /* mode */
+  TRUE, /* immutable */
 
+  0, /* length */
   NULL, /* data */
+  HB_MEMORY_MODE_READONLY, /* mode */
 
   NULL, /* user_data */
   NULL  /* destroy */
 };
 
+
+static bool _try_writable (hb_blob_t *blob);
+
 static void
 _hb_blob_destroy_user_data (hb_blob_t *blob)
 {
@@ -91,13 +86,6 @@ _hb_blob_destroy_user_data (hb_blob_t *blob)
   }
 }
 
-static void
-_hb_blob_unlock_and_destroy (hb_blob_t *blob)
-{
-  hb_blob_unlock (blob);
-  hb_blob_destroy (blob);
-}
-
 hb_blob_t *
 hb_blob_create (const char        *data,
 		unsigned int       length,
@@ -113,9 +101,6 @@ hb_blob_create (const char        *data,
     return &_hb_blob_nil;
   }
 
-  hb_mutex_init (&blob->lock);
-  blob->lock_count = 0;
-
   blob->data = data;
   blob->length = length;
   blob->mode = mode;
@@ -125,7 +110,7 @@ hb_blob_create (const char        *data,
 
   if (blob->mode == HB_MEMORY_MODE_DUPLICATE) {
     blob->mode = HB_MEMORY_MODE_READONLY;
-    if (!hb_blob_try_writable (blob)) {
+    if (!_try_writable (blob)) {
       hb_blob_destroy (blob);
       return &_hb_blob_nil;
     }
@@ -140,20 +125,17 @@ hb_blob_create_sub_blob (hb_blob_t    *parent,
 			 unsigned int  length)
 {
   hb_blob_t *blob;
-  const char *pdata;
 
   if (!length || offset >= parent->length || !(blob = hb_object_create<hb_blob_t> ()))
     return &_hb_blob_nil;
 
-  pdata = hb_blob_lock (parent);
+  hb_blob_make_immutable (parent);
 
-  hb_mutex_lock (&parent->lock);
-  blob = hb_blob_create (pdata + offset,
+  blob = hb_blob_create (parent->data + offset,
 			 MIN (length, parent->length - offset),
 			 parent->mode,
 			 hb_blob_reference (parent),
-			 (hb_destroy_func_t) _hb_blob_unlock_and_destroy);
-  hb_mutex_unlock (&parent->lock);
+			 (hb_destroy_func_t) hb_blob_destroy);
 
   return blob;
 }
@@ -176,7 +158,6 @@ hb_blob_destroy (hb_blob_t *blob)
   if (!hb_object_destroy (blob)) return;
 
   _hb_blob_destroy_user_data (blob);
-  hb_mutex_free (&blob->lock);
 
   free (blob);
 }
@@ -198,69 +179,56 @@ hb_blob_get_user_data (hb_blob_t          *blob,
 }
 
 
-unsigned int
-hb_blob_get_length (hb_blob_t *blob)
-{
-  return blob->length;
-}
-
-const char *
-hb_blob_lock (hb_blob_t *blob)
-{
-  if (hb_object_is_inert (blob))
-    return NULL;
-
-  hb_mutex_lock (&blob->lock);
-
-  (void) (HB_DEBUG_BLOB &&
-    fprintf (stderr, "%p %s (%d) -> %p\n", blob, HB_FUNC,
-	     blob->lock_count, blob->data));
-
-  blob->lock_count++;
-
-  hb_mutex_unlock (&blob->lock);
-
-  return blob->data;
-}
-
 void
-hb_blob_unlock (hb_blob_t *blob)
+hb_blob_make_immutable (hb_blob_t *blob)
 {
   if (hb_object_is_inert (blob))
     return;
 
-  hb_mutex_lock (&blob->lock);
+  blob->immutable = TRUE;
+}
 
-  (void) (HB_DEBUG_BLOB &&
-    fprintf (stderr, "%p %s (%d) -> %p\n", blob, HB_FUNC,
-	     blob->lock_count, blob->data));
+hb_bool_t
+hb_blob_is_immutable (hb_blob_t *blob)
+{
+  return blob->immutable;
+}
 
-  assert (blob->lock_count > 0);
-  blob->lock_count--;
 
-  hb_mutex_unlock (&blob->lock);
+unsigned int
+hb_blob_get_length (hb_blob_t *blob)
+{
+  return blob->length;
 }
 
-hb_bool_t
-hb_blob_is_writable (hb_blob_t *blob)
+const char *
+hb_blob_get_data (hb_blob_t *blob, unsigned int *length)
 {
-  hb_memory_mode_t mode;
+  if (length)
+    *length = blob->length;
 
-  if (hb_object_is_inert (blob))
-    return FALSE;
+  return blob->data;
+}
 
-  hb_mutex_lock (&blob->lock);
+char *
+hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length)
+{
+  if (!_try_writable (blob)) {
+    if (length)
+      *length = 0;
 
-  mode = blob->mode;
+    return NULL;
+  }
 
-  hb_mutex_unlock (&blob->lock);
+  if (length)
+    *length = blob->length;
 
-  return mode == HB_MEMORY_MODE_WRITABLE;
+  return const_cast<char *> (blob->data);
 }
 
 
 static hb_bool_t
-_try_make_writable_inplace_unix_locked (hb_blob_t *blob)
+_try_make_writable_inplace_unix (hb_blob_t *blob)
 {
 #if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MPROTECT)
   uintptr_t pagesize = -1, mask, length;
@@ -295,6 +263,8 @@ _try_make_writable_inplace_unix_locked (hb_blob_t *blob)
     return FALSE;
   }
 
+  blob->mode = HB_MEMORY_MODE_WRITABLE;
+
   (void) (HB_DEBUG_BLOB &&
     fprintf (stderr, "%p %s: successfully made [%p..%p] (%lu bytes) writable\n",
 	     blob, HB_FUNC,
@@ -305,67 +275,59 @@ _try_make_writable_inplace_unix_locked (hb_blob_t *blob)
 #endif
 }
 
-static void
-try_writable_inplace_locked (hb_blob_t *blob)
+static bool
+_try_writable_inplace (hb_blob_t *blob)
 {
   (void) (HB_DEBUG_BLOB &&
-    fprintf (stderr, "%p %s: making writable\n", blob, HB_FUNC));
+    fprintf (stderr, "%p %s: making writable inplace\n", blob, HB_FUNC));
 
-  if (_try_make_writable_inplace_unix_locked (blob)) {
-    (void) (HB_DEBUG_BLOB &&
-      fprintf (stderr, "%p %s: making writable -> succeeded\n", blob, HB_FUNC));
-    blob->mode = HB_MEMORY_MODE_WRITABLE;
-  } else {
-    (void) (HB_DEBUG_BLOB &&
-      fprintf (stderr, "%p %s: making writable -> FAILED\n", blob, HB_FUNC));
-    /* Failed to make writable inplace, mark that */
-    blob->mode = HB_MEMORY_MODE_READONLY;
-  }
+  if (_try_make_writable_inplace_unix (blob))
+    return TRUE;
+
+  (void) (HB_DEBUG_BLOB &&
+    fprintf (stderr, "%p %s: making writable -> FAILED\n", blob, HB_FUNC));
+
+  /* Failed to make writable inplace, mark that */
+  blob->mode = HB_MEMORY_MODE_READONLY;
+  return FALSE;
 }
 
-hb_bool_t
-hb_blob_try_writable (hb_blob_t *blob)
+static bool
+_try_writable (hb_blob_t *blob)
 {
-  hb_memory_mode_t mode;
-
-  if (hb_object_is_inert (blob))
+  if (blob->immutable)
     return FALSE;
 
-  hb_mutex_lock (&blob->lock);
+  if (blob->mode == HB_MEMORY_MODE_WRITABLE)
+    return TRUE;
 
-  if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE)
-    try_writable_inplace_locked (blob);
+  if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE && _try_writable_inplace (blob))
+    return TRUE;
 
-  if (blob->mode == HB_MEMORY_MODE_READONLY)
-  {
-    char *new_data;
+  if (blob->mode == HB_MEMORY_MODE_WRITABLE)
+    return TRUE;
 
-    (void) (HB_DEBUG_BLOB &&
-      fprintf (stderr, "%p %s (%d) -> %p\n", blob, HB_FUNC,
-	       blob->lock_count, blob->data));
-
-    if (blob->lock_count)
-      goto done;
-
-    new_data = (char *) malloc (blob->length);
-    if (new_data) {
-      (void) (HB_DEBUG_BLOB &&
-	fprintf (stderr, "%p %s: dupped successfully -> %p\n", blob, HB_FUNC, blob->data));
-      memcpy (new_data, blob->data, blob->length);
-      _hb_blob_destroy_user_data (blob);
-      blob->mode = HB_MEMORY_MODE_WRITABLE;
-      blob->data = new_data;
-      blob->user_data = new_data;
-      blob->destroy = free;
-    }
-  }
 
-done:
-  mode = blob->mode;
+  (void) (HB_DEBUG_BLOB &&
+    fprintf (stderr, "%p %s -> %p\n", blob, HB_FUNC, blob->data));
+
+  char *new_data;
+
+  new_data = (char *) malloc (blob->length);
+  if (unlikely (!new_data))
+    return FALSE;
 
-  hb_mutex_unlock (&blob->lock);
+  (void) (HB_DEBUG_BLOB &&
+    fprintf (stderr, "%p %s: dupped successfully -> %p\n", blob, HB_FUNC, blob->data));
 
-  return mode == HB_MEMORY_MODE_WRITABLE;
+  memcpy (new_data, blob->data, blob->length);
+  _hb_blob_destroy_user_data (blob);
+  blob->mode = HB_MEMORY_MODE_WRITABLE;
+  blob->data = new_data;
+  blob->user_data = new_data;
+  blob->destroy = free;
+
+  return TRUE;
 }
 
 
diff --git a/src/hb-blob.h b/src/hb-blob.h
index 3ec35a8..f2eaae9 100644
--- a/src/hb-blob.h
+++ b/src/hb-blob.h
@@ -74,20 +74,21 @@ hb_blob_get_user_data (hb_blob_t          *blob,
 		       hb_user_data_key_t *key);
 
 
+void
+hb_blob_make_immutable (hb_blob_t *blob);
+
+hb_bool_t
+hb_blob_is_immutable (hb_blob_t *blob);
+
+
 unsigned int
 hb_blob_get_length (hb_blob_t *blob);
 
 const char *
-hb_blob_lock (hb_blob_t *blob);
+hb_blob_get_data (hb_blob_t *blob, unsigned int *length);
 
-void
-hb_blob_unlock (hb_blob_t *blob);
-
-hb_bool_t
-hb_blob_is_writable (hb_blob_t *blob);
-
-hb_bool_t
-hb_blob_try_writable (hb_blob_t *blob);
+char *
+hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length);
 
 
 HB_END_DECLS
diff --git a/src/hb-font.cc b/src/hb-font.cc
index e41ceec..1e7734b 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -361,8 +361,6 @@ _hb_face_for_data_get_table (hb_tag_t tag, void *user_data)
 
   hb_blob_t *blob = hb_blob_create_sub_blob (data->blob, table.offset, table.length);
 
-  hb_blob_unlock (data->blob);
-
   return blob;
 }
 
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 20df95b..e16eddd 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -186,9 +186,13 @@ struct hb_sanitize_context_t
   inline void init (hb_blob_t *blob)
   {
     this->blob = hb_blob_reference (blob);
-    this->start = hb_blob_lock (blob);
+    this->writable = false;
+  }
+
+  inline void setup (void)
+  {
+    this->start = hb_blob_get_data (blob, NULL);
     this->end = this->start + hb_blob_get_length (blob);
-    this->writable = hb_blob_is_writable (blob);
     this->edit_count = 0;
     this->debug_depth = 0;
 
@@ -204,7 +208,6 @@ struct hb_sanitize_context_t
       fprintf (stderr, "sanitize %p fini [%p..%p] %u edit requests\n",
 	       this->blob, this->start, this->end, this->edit_count));
 
-    hb_blob_unlock (this->blob);
     hb_blob_destroy (this->blob);
     this->blob = NULL;
     this->start = this->end = NULL;
@@ -286,11 +289,13 @@ struct Sanitizer
 
     /* TODO is_sane() stuff */
 
+    c->init (blob);
+
   retry:
     (void) (HB_DEBUG_SANITIZE &&
       fprintf (stderr, "Sanitizer %p start %s\n", blob, HB_FUNC));
 
-    c->init (blob);
+    c->setup ();
 
     if (unlikely (!c->start)) {
       c->finish ();
@@ -320,11 +325,17 @@ struct Sanitizer
     } else {
       unsigned int edit_count = c->edit_count;
       c->finish ();
-      if (edit_count && !hb_blob_is_writable (blob) && hb_blob_try_writable (blob)) {
-        /* ok, we made it writable by relocating.  try again */
-	(void) (HB_DEBUG_SANITIZE &&
-	  fprintf (stderr, "Sanitizer %p retry %s\n", blob, HB_FUNC));
-        goto retry;
+      if (edit_count && !c->writable) {
+        c->start = hb_blob_get_data_writable (blob, NULL);
+	c->end = c->start + hb_blob_get_length (blob);
+
+	if (c->start) {
+	  c->writable = true;
+	  /* ok, we made it writable by relocating.  try again */
+	  (void) (HB_DEBUG_SANITIZE &&
+	    fprintf (stderr, "Sanitizer %p retry %s\n", blob, HB_FUNC));
+	  goto retry;
+	}
       }
     }
 
@@ -339,7 +350,8 @@ struct Sanitizer
   }
 
   static const Type* lock_instance (hb_blob_t *blob) {
-    const char *base = hb_blob_lock (blob);
+    hb_blob_make_immutable (blob);
+    const char *base = hb_blob_get_data (blob, NULL);
     return unlikely (!base) ? &Null(Type) : CastP<Type> (base);
   }
 };
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 7383e9f..7e1e966 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -45,7 +45,7 @@ HB_BEGIN_DECLS
 hb_ot_layout_t *
 _hb_ot_layout_create (hb_face_t *face)
 {
-  /* Remove this object altogether */
+  /* TODO Remove this object altogether */
   hb_ot_layout_t *layout = (hb_ot_layout_t *) calloc (1, sizeof (hb_ot_layout_t));
 
   layout->gdef_blob = Sanitizer<GDEF>::sanitize (hb_face_reference_table (face, HB_OT_TAG_GDEF));
@@ -66,11 +66,6 @@ _hb_ot_layout_create (hb_face_t *face)
 void
 _hb_ot_layout_destroy (hb_ot_layout_t *layout)
 {
-  hb_blob_unlock (layout->gdef_blob);
-  hb_blob_unlock (layout->gsub_blob);
-  hb_blob_unlock (layout->gpos_blob);
-  hb_blob_unlock (layout->head_blob);
-
   hb_blob_destroy (layout->gdef_blob);
   hb_blob_destroy (layout->gsub_blob);
   hb_blob_destroy (layout->gpos_blob);
diff --git a/test/test-object.c b/test/test-object.c
index 3662d30..4936172 100644
--- a/test/test-object.c
+++ b/test/test-object.c
@@ -159,10 +159,10 @@ typedef struct {
   }
 static const object_t objects[] =
 {
-  OBJECT_WITHOUT_IMMUTABILITY (blob),
   OBJECT_WITHOUT_IMMUTABILITY (buffer),
   OBJECT_WITHOUT_IMMUTABILITY (face),
   OBJECT_WITHOUT_IMMUTABILITY (font),
+  OBJECT_WITH_IMMUTABILITY (blob),
   OBJECT_WITH_IMMUTABILITY (font_funcs),
   OBJECT_WITH_IMMUTABILITY (unicode_funcs)
 };
commit 71cef14ac3de07e4fed0a2903b1f0f639406ec6c
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri May 6 19:30:59 2011 -0400

    Add -Bsymbolic-functions to linker flags

diff --git a/configure.ac b/configure.ac
index bb25950..2eb6c11 100644
--- a/configure.ac
+++ b/configure.ac
@@ -41,6 +41,9 @@ AC_CHECK_HEADERS(unistd.h sys/mman.h)
 AC_CANONICAL_HOST
 if test "x$GCC" = "xyes"; then
 
+	# Make symbols link locally
+	LDFLAGS="$LDFLAGS -Bsymbolic-functions"
+
 	# Make sure we don't link to libstdc++
 	CXXFLAGS="$CXXFLAGS -fno-rtti -fno-exceptions"
 
commit ab428aeab724ca40341318b66640f992cd72d2fc
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri May 6 19:30:46 2011 -0400

    [TODO] Update

diff --git a/TODO b/TODO
index 1152d5e..a05900d 100644
--- a/TODO
+++ b/TODO
@@ -32,7 +32,7 @@ API to add (maybe after 1.0):
 
 - Add query API for aalt-like features?
 
-- SFNT api? get_num_faces?
+- SFNT api? get_num_faces? get_table_tags? (there's something in stash)
 
 - Full matrix instead of scale?
 
commit a0f337a1cce1788dbf3147b459e7f615acbfe81b
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri May 6 19:20:52 2011 -0400

    Remove unused hb_blob_try_writable_inplace()

diff --git a/src/hb-blob.cc b/src/hb-blob.cc
index 664ad78..b903acc 100644
--- a/src/hb-blob.cc
+++ b/src/hb-blob.cc
@@ -324,26 +324,6 @@ try_writable_inplace_locked (hb_blob_t *blob)
 }
 
 hb_bool_t
-hb_blob_try_writable_inplace (hb_blob_t *blob)
-{
-  hb_memory_mode_t mode;
-
-  if (hb_object_is_inert (blob))
-    return FALSE;
-
-  hb_mutex_lock (&blob->lock);
-
-  if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE)
-    try_writable_inplace_locked (blob);
-
-  mode = blob->mode;
-
-  hb_mutex_unlock (&blob->lock);
-
-  return mode == HB_MEMORY_MODE_WRITABLE;
-}
-
-hb_bool_t
 hb_blob_try_writable (hb_blob_t *blob)
 {
   hb_memory_mode_t mode;
diff --git a/src/hb-blob.h b/src/hb-blob.h
index 8bfbd48..3ec35a8 100644
--- a/src/hb-blob.h
+++ b/src/hb-blob.h
@@ -87,9 +87,6 @@ hb_bool_t
 hb_blob_is_writable (hb_blob_t *blob);
 
 hb_bool_t
-hb_blob_try_writable_inplace (hb_blob_t *blob);
-
-hb_bool_t
 hb_blob_try_writable (hb_blob_t *blob);
 
 
commit 08611d5194144bbf5d96a1110aeb812db06e0901
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri May 6 16:28:10 2011 -0400

    Add note re deadlocks

diff --git a/src/hb-common.cc b/src/hb-common.cc
index a223edb..02314b3 100644
--- a/src/hb-common.cc
+++ b/src/hb-common.cc
@@ -293,6 +293,7 @@ hb_script_get_horizontal_direction (hb_script_t script)
  * should switch to using that insted for these too.
  */
 
+/* XXX  this can result in deadlocks because we call user callbacks */
 static hb_static_mutex_t user_data_mutex;
 
 bool
diff --git a/src/hb-mutex-private.hh b/src/hb-mutex-private.hh
index 65e5892..b52d970 100644
--- a/src/hb-mutex-private.hh
+++ b/src/hb-mutex-private.hh
@@ -111,6 +111,10 @@ struct hb_static_mutex_t : hb_mutex_t
 HB_END_DECLS
 
 
+/* XXX If the finish() callbacks of items in the set recursively try to
+ * modify the set, deadlock occurs.  This needs fixing in set proper in
+ * fact. */
+
 template <typename item_t>
 struct hb_threadsafe_set_t
 {



More information about the HarfBuzz mailing list