summaryrefslogtreecommitdiff
path: root/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff-common.hh
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff-common.hh')
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff-common.hh50
1 files changed, 19 insertions, 31 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff-common.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff-common.hh
index 8b8e592013a..aced77c83de 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff-common.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cff-common.hh
@@ -40,14 +40,14 @@ using namespace OT;
/* utility macro */
template<typename Type>
-static inline const Type& StructAtOffsetOrNull(const void *P, unsigned int offset)
-{ return offset? (* reinterpret_cast<const Type*> ((const char *) P + offset)): Null(Type); }
+static inline const Type& StructAtOffsetOrNull (const void *P, unsigned int offset)
+{ return offset ? StructAtOffset<Type> (P, offset) : Null (Type); }
-inline unsigned int calcOffSize(unsigned int dataSize)
+inline unsigned int calcOffSize (unsigned int dataSize)
{
unsigned int size = 1;
unsigned int offset = dataSize + 1;
- while ((offset & ~0xFF) != 0)
+ while (offset & ~0xFF)
{
size++;
offset >>= 8;
@@ -58,8 +58,8 @@ inline unsigned int calcOffSize(unsigned int dataSize)
struct code_pair_t
{
- hb_codepoint_t code;
- hb_codepoint_t glyph;
+ hb_codepoint_t code;
+ hb_codepoint_t glyph;
};
typedef hb_vector_t<unsigned char> str_buff_t;
@@ -92,10 +92,8 @@ struct CFFIndex
static unsigned int calculate_serialized_size (unsigned int offSize_, unsigned int count,
unsigned int dataSize)
{
- if (count == 0)
- return COUNT::static_size;
- else
- return min_size + calculate_offset_array_size (offSize_, count) + dataSize;
+ if (count == 0) return COUNT::static_size;
+ return min_size + calculate_offset_array_size (offSize_, count) + dataSize;
}
bool serialize (hb_serialize_context_t *c, const CFFIndex &src)
@@ -159,9 +157,7 @@ struct CFFIndex
byteArray.init ();
byteArray.resize (buffArray.length);
for (unsigned int i = 0; i < byteArray.length; i++)
- {
byteArray[i] = byte_str_t (buffArray[i].arrayZ, buffArray[i].length);
- }
bool result = this->serialize (c, offSize_, byteArray);
byteArray.fini ();
return result;
@@ -192,43 +188,35 @@ struct CFFIndex
unsigned int length_at (unsigned int index) const
{
- if (likely ((offset_at (index + 1) >= offset_at (index)) &&
- (offset_at (index + 1) <= offset_at (count))))
- return offset_at (index + 1) - offset_at (index);
- else
+ if (unlikely ((offset_at (index + 1) < offset_at (index)) ||
+ (offset_at (index + 1) > offset_at (count))))
return 0;
+ return offset_at (index + 1) - offset_at (index);
}
const unsigned char *data_base () const
- { return (const unsigned char *)this + min_size + offset_array_size (); }
+ { return (const unsigned char *) this + min_size + offset_array_size (); }
unsigned int data_size () const { return HBINT8::static_size; }
byte_str_t operator [] (unsigned int index) const
{
- if (likely (index < count))
- return byte_str_t (data_base () + offset_at (index) - 1, length_at (index));
- else
- return Null (byte_str_t);
+ if (unlikely (index >= count)) return Null (byte_str_t);
+ return byte_str_t (data_base () + offset_at (index) - 1, length_at (index));
}
unsigned int get_size () const
{
- if (this != &Null (CFFIndex))
- {
- if (count > 0)
- return min_size + offset_array_size () + (offset_at (count) - 1);
- else
- return count.static_size; /* empty CFFIndex contains count only */
- }
- else
- return 0;
+ if (this == &Null (CFFIndex)) return 0;
+ if (count > 0)
+ return min_size + offset_array_size () + (offset_at (count) - 1);
+ return count.static_size; /* empty CFFIndex contains count only */
}
bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (likely ((count.sanitize (c) && count == 0) || /* empty INDEX */
+ return_trace (likely ((c->check_struct (this) && count == 0) || /* empty INDEX */
(c->check_struct (this) && offSize >= 1 && offSize <= 4 &&
c->check_array (offsets, offSize, count + 1) &&
c->check_array ((const HBUINT8*) data_base (), 1, max_offset () - 1))));