From 51f563579b94e1ee23ced9bbcc7dd3341535ce72 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 4 Jun 2014 18:42:32 -0400 Subject: [PATCH] Move try_set to sanitize context --- src/hb-open-type-private.hh | 22 ++++++++++------------ src/hb-ot-layout-common-private.hh | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 965d4d7ad..fcdee025f 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -266,6 +266,15 @@ struct hb_sanitize_context_t return TRACE_RETURN (this->writable); } + template + inline bool try_set (Type *obj, const ValueType &v) { + if (this->may_edit (obj, obj->static_size)) { + obj->set (v); + return true; + } + return false; + } + mutable unsigned int debug_depth; const char *start, *end; bool writable; @@ -722,20 +731,9 @@ struct GenericOffsetTo : OffsetType return TRACE_RETURN (likely (obj.sanitize (c, user_data)) || neuter (c)); } - inline bool try_set (hb_sanitize_context_t *c, const OffsetType &v) { - if (c->may_edit (this, this->static_size)) { - this->set (v); - return true; - } - return false; - } /* Set the offset to Null */ inline bool neuter (hb_sanitize_context_t *c) { - if (c->may_edit (this, this->static_size)) { - this->set (0); /* 0 is Null offset */ - return true; - } - return false; + return c->try_set (this, 0); } }; template diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index 4c6792fbc..688bf6555 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -519,7 +519,7 @@ struct Feature /* Check that it did not overflow. */ new_offset.set (new_offset_int); if (new_offset == new_offset_int && - featureParams.try_set (c, new_offset) && + c->try_set (&featureParams, new_offset) && !featureParams.sanitize (c, this, closure ? closure->tag : HB_TAG_NONE)) return TRACE_RETURN (false); }