[pango] [HB] Remove HB_MEMORY_MODE_READONLY_NEVER_DUPLICATE



commit 392f1f1ddb24c0e7d1d64ee8d36c739ac6482b81
Author: Behdad Esfahbod <behdad behdad org>
Date:   Wed Aug 19 16:45:41 2009 -0400

    [HB] Remove HB_MEMORY_MODE_READONLY_NEVER_DUPLICATE
    
    Unlike the rest of the memory-mode enum, this one didn't only
    describe the access mode of the input memory region.  Remove it.
    
    If someone wants to inhibit duplicating, they can lock the blob
    and throw away the key.
    
    Based on mailing list discussion with Carl Worth.

 pango/opentype/hb-blob.c |   51 ++++++++++++++++++++++-----------------------
 pango/opentype/hb-blob.h |    1 -
 2 files changed, 25 insertions(+), 27 deletions(-)
---
diff --git a/pango/opentype/hb-blob.c b/pango/opentype/hb-blob.c
index a1ab7f3..5f54753 100644
--- a/pango/opentype/hb-blob.c
+++ b/pango/opentype/hb-blob.c
@@ -59,7 +59,7 @@ static hb_blob_t _hb_blob_nil = {
   HB_MUTEX_INIT, /* lock */
 
   0, /* lock_count */
-  HB_MEMORY_MODE_READONLY_NEVER_DUPLICATE, /* mode */
+  HB_MEMORY_MODE_READONLY, /* mode */
 
   NULL, /* data */
 
@@ -286,6 +286,26 @@ _try_make_writable_inplace_unix_locked (hb_blob_t *blob)
 #endif
 }
 
+static void
+_try_writable_inplace_locked (hb_blob_t *blob)
+{
+#if HB_DEBUG
+  fprintf (stderr, "%p %s: making writable\n", blob, __FUNCTION__);
+#endif
+
+  if (_try_make_writable_inplace_unix_locked (blob)) {
+#if HB_DEBUG
+  fprintf (stderr, "%p %s: making writable -> succeeded\n", blob, __FUNCTION__);
+#endif
+    blob->mode = HB_MEMORY_MODE_WRITABLE;
+  } else {
+#if HB_DEBUG
+  fprintf (stderr, "%p %s: making writable -> FAILED\n", blob, __FUNCTION__);
+#endif
+    /* Failed to make writable inplace, mark that */
+    blob->mode = HB_MEMORY_MODE_READONLY;
+  }
+}
 
 hb_bool_t
 hb_blob_try_writable_inplace (hb_blob_t *blob)
@@ -297,25 +317,8 @@ hb_blob_try_writable_inplace (hb_blob_t *blob)
 
   hb_mutex_lock (blob->lock);
 
-  if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE) {
-
-#if HB_DEBUG
-    fprintf (stderr, "%p %s: making writable\n", blob, __FUNCTION__);
-#endif
-
-    if (_try_make_writable_inplace_unix_locked (blob)) {
-#if HB_DEBUG
-    fprintf (stderr, "%p %s: making writable -> succeeded\n", blob, __FUNCTION__);
-#endif
-      blob->mode = HB_MEMORY_MODE_WRITABLE;
-    } else {
-#if HB_DEBUG
-    fprintf (stderr, "%p %s: making writable -> FAILED\n", blob, __FUNCTION__);
-#endif
-      /* Failed to make writable inplace, mark that */
-      blob->mode = HB_MEMORY_MODE_READONLY;
-    }
-  }
+  if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE)
+    _try_writable_inplace_locked (blob);
 
   mode = blob->mode;
 
@@ -334,9 +337,6 @@ hb_blob_try_writable (hb_blob_t *blob)
 
   hb_mutex_lock (blob->lock);
 
-  if (blob->mode == HB_MEMORY_MODE_READONLY_NEVER_DUPLICATE)
-    goto done;
-
   if (blob->mode == HB_MEMORY_MODE_READONLY)
   {
     char *new_data;
@@ -360,14 +360,13 @@ hb_blob_try_writable (hb_blob_t *blob)
       _hb_blob_destroy_user_data (blob);
     }
   }
+  else if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE)
+    _try_writable_inplace_locked (blob);
 
 done:
   mode = blob->mode;
 
   hb_mutex_unlock (blob->lock);
 
-  if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE)
-    return hb_blob_try_writable_inplace (blob);
-
   return mode == HB_MEMORY_MODE_WRITABLE;
 }
diff --git a/pango/opentype/hb-blob.h b/pango/opentype/hb-blob.h
index 1a58f15..131a282 100644
--- a/pango/opentype/hb-blob.h
+++ b/pango/opentype/hb-blob.h
@@ -35,7 +35,6 @@ typedef enum {
   HB_MEMORY_MODE_DUPLICATE,
   HB_MEMORY_MODE_READONLY,
   HB_MEMORY_MODE_WRITABLE,
-  HB_MEMORY_MODE_READONLY_NEVER_DUPLICATE,
   HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE
 } hb_memory_mode_t;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]