Move try_set to sanitize context

pull/43/merge
Behdad Esfahbod 11 years ago
parent 500737e8e1
commit 51f563579b
  1. 22
      src/hb-open-type-private.hh
  2. 2
      src/hb-ot-layout-common-private.hh

@ -266,6 +266,15 @@ struct hb_sanitize_context_t
return TRACE_RETURN (this->writable);
}
template <typename Type, typename ValueType>
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 <typename Base, typename OffsetType, typename Type>

@ -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);
}

Loading…
Cancel
Save