summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2009-08-04 15:28:49 -0400
committerBehdad Esfahbod <behdad@behdad.org>2009-08-04 15:28:49 -0400
commit6a4933ab14b6786fc7f347f1e1c41c0b038a0a6f (patch)
tree4c53401a7578e775c902ae1d2d1d1bb413cfb736
parentf92f7d301c7219cc1478759e2a5729cfba821529 (diff)
downloadpango-6a4933ab14b6786fc7f347f1e1c41c0b038a0a6f.tar.gz
[HB] More sanitize infrastructure
-rw-r--r--pango/opentype/hb-open-types-private.hh29
1 files changed, 28 insertions, 1 deletions
diff --git a/pango/opentype/hb-open-types-private.hh b/pango/opentype/hb-open-types-private.hh
index 9d7894c7..8429179e 100644
--- a/pango/opentype/hb-open-types-private.hh
+++ b/pango/opentype/hb-open-types-private.hh
@@ -59,9 +59,36 @@ typedef struct _hb_sanitize_context_t hb_sanitize_context_t;
struct _hb_sanitize_context_t
{
const char *start, *end;
+ int edit_count;
hb_blob_t *blob;
};
+static HB_GNUC_UNUSED void
+hb_sanitize_init (hb_sanitize_context_t *context,
+ hb_blob_t *blob)
+{
+ context->blob = blob;
+ context->start = hb_blob_lock (blob);
+ context->end = context->start + hb_blob_get_length (blob);
+ context->edit_count = 0;
+}
+
+static HB_GNUC_UNUSED void
+hb_sanitize_fini (hb_sanitize_context_t *context, bool unlock)
+{
+ if (unlock)
+ hb_blob_unlock (context->blob);
+}
+
+static HB_GNUC_UNUSED bool
+hb_sanitize_edit (hb_sanitize_context_t *context)
+{
+ bool perm = hb_blob_try_writeable_inplace (context->blob);
+ if (perm)
+ context->edit_count++;
+ return perm;
+}
+
#define SANITIZE_ARG_DEF \
hb_sanitize_context_t *context
#define SANITIZE_ARG \
@@ -83,7 +110,7 @@ struct _hb_sanitize_context_t
#define SANITIZE_MEM(B,L) HB_LIKELY (context->start <= CONST_CHARP(B) && CONST_CHARP(B) + (L) <= context->end) /* XXX overflow */
-#define NEUTER(Var, Val) (SANITIZE_OBJ (Var) && hb_blob_try_writeable_inplace (context->blob) && ((Var) = (Val), true))
+#define NEUTER(Var, Val) (SANITIZE_OBJ (Var) && hb_sanitize_edit (context) && ((Var) = (Val), true))
/*