diff options
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff-interp-common.hh')
-rw-r--r-- | Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff-interp-common.hh | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff-interp-common.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff-interp-common.hh index 780f61892d7..91a9b7d0d16 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff-interp-common.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-cff-interp-common.hh @@ -252,30 +252,27 @@ struct number_t struct UnsizedByteStr : UnsizedArrayOf <HBUINT8> { // encode 2-byte int (Dict/CharString) or 4-byte int (Dict) - template <typename INTTYPE, int minVal, int maxVal> - static bool serialize_int (hb_serialize_context_t *c, op_code_t intOp, int value) + template <typename T, typename V> + static bool serialize_int (hb_serialize_context_t *c, op_code_t intOp, V value) { TRACE_SERIALIZE (this); - if (unlikely ((value < minVal || value > maxVal))) - return_trace (false); - HBUINT8 *p = c->allocate_size<HBUINT8> (1); - if (unlikely (p == nullptr)) return_trace (false); + if (unlikely (!p)) return_trace (false); *p = intOp; - INTTYPE *ip = c->allocate_size<INTTYPE> (INTTYPE::static_size); - if (unlikely (ip == nullptr)) return_trace (false); - *ip = (unsigned int) value; - - return_trace (true); + T *ip = c->allocate_size<T> (T::static_size); + if (unlikely (!ip)) return_trace (false); + return_trace (c->check_assign (*ip, value)); } - static bool serialize_int4 (hb_serialize_context_t *c, int value) - { return serialize_int<HBUINT32, 0, 0x7FFFFFFF> (c, OpCode_longintdict, value); } + template <typename V> + static bool serialize_int4 (hb_serialize_context_t *c, V value) + { return serialize_int<HBINT32> (c, OpCode_longintdict, value); } - static bool serialize_int2 (hb_serialize_context_t *c, int value) - { return serialize_int<HBUINT16, 0, 0x7FFF> (c, OpCode_shortint, value); } + template <typename V> + static bool serialize_int2 (hb_serialize_context_t *c, V value) + { return serialize_int<HBINT16> (c, OpCode_shortint, value); } /* Defining null_size allows a Null object may be created. Should be safe because: * A descendent struct Dict uses a Null pointer to indicate a missing table, @@ -408,7 +405,7 @@ struct cff_stack_t else { set_error (); - return Crap(ELEM); + return Crap (ELEM); } } @@ -419,7 +416,7 @@ struct cff_stack_t else { set_error (); - return Crap(ELEM); + return Crap (ELEM); } } void pop (unsigned int n) @@ -435,7 +432,7 @@ struct cff_stack_t if (unlikely (count < 0)) { set_error (); - return Null(ELEM); + return Null (ELEM); } return elements[count - 1]; } @@ -542,7 +539,7 @@ struct op_serializer_t TRACE_SERIALIZE (this); HBUINT8 *d = c->allocate_size<HBUINT8> (opstr.str.length); - if (unlikely (d == nullptr)) return_trace (false); + if (unlikely (!d)) return_trace (false); memcpy (d, &opstr.str[0], opstr.str.length); return_trace (true); } |