From: Behdad Esfahbod Date: Tue, 4 Aug 2009 14:23:01 +0000 (-0400) Subject: [HB] Simplify indirect sanitize() X-Git-Tag: submit/master/20120920.151126~7^2~1092 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e6ab2c59ba2d37942ac5fcbfe61d38b7e359ac8c;p=framework%2Fuifw%2Fharfbuzz.git [HB] Simplify indirect sanitize() --- diff --git a/src/hb-open-types-private.hh b/src/hb-open-types-private.hh index b3d7541..198c0ad 100644 --- a/src/hb-open-types-private.hh +++ b/src/hb-open-types-private.hh @@ -383,6 +383,13 @@ struct ArrayOf return false; */ } + inline bool sanitize (SANITIZE_ARG_DEF, const char *base) { + if (!(SANITIZE (len) && SANITIZE_GET_SIZE())) return false; + unsigned int count = len; + for (unsigned int i = 0; i < count; i++) + if (!SANITIZE_THIS (array[i])) + return false; + } USHORT len; Type array[]; @@ -410,6 +417,13 @@ struct HeadlessArrayOf return false; */ } + inline bool sanitize (SANITIZE_ARG_DEF, const char *base) { + if (!(SANITIZE (len) && SANITIZE_GET_SIZE())) return false; + unsigned int count = len; + for (unsigned int i = 0; i < count; i++) + if (!SANITIZE_THIS (array[i])) + return false; + } USHORT len; Type array[]; @@ -436,6 +450,13 @@ struct LongArrayOf return false; */ } + inline bool sanitize (SANITIZE_ARG_DEF, const char *base) { + if (!(SANITIZE (len) && SANITIZE_GET_SIZE())) return false; + unsigned int count = len; + for (unsigned int i = 0; i < count; i++) + if (!SANITIZE_THIS (array[i])) + return false; + } ULONG len; Type array[]; @@ -443,39 +464,16 @@ struct LongArrayOf /* Array of Offset's */ template -struct OffsetArrayOf : ArrayOf > { - inline bool sanitize (SANITIZE_ARG_DEF, const char *base) { - if (!(SANITIZE (this->len) && SANITIZE_GET_SIZE())) return false; - unsigned int count = this->len; - for (unsigned int i = 0; i < count; i++) - if (!this->array[i].sanitize (SANITIZE_ARG, base)) - return false; - } -}; +struct OffsetArrayOf : ArrayOf > {}; /* Array of LongOffset's */ template -struct LongOffsetArrayOf : ArrayOf > { - inline bool sanitize (SANITIZE_ARG_DEF, const char *base) { - if (!(SANITIZE (this->len) && SANITIZE_GET_SIZE())) return false; - unsigned int count = this->len; - for (unsigned int i = 0; i < count; i++) - if (!this->array[i].sanitize (SANITIZE_ARG, base)) - return false; - } -}; +struct LongOffsetArrayOf : ArrayOf > {}; /* LongArray of LongOffset's */ template -struct LongOffsetLongArrayOf : LongArrayOf > { - inline bool sanitize (SANITIZE_ARG_DEF, const char *base) { - if (!(SANITIZE (this->len) && SANITIZE_GET_SIZE())) return false; - unsigned int count = this->len; - for (unsigned int i = 0; i < count; i++) - if (!this->array[i].sanitize (SANITIZE_ARG, base)) - return false; - } -}; +struct LongOffsetLongArrayOf : LongArrayOf > {}; + /* An array type is one that contains a variable number of objects * as its last item. An array object is extended with get_len() diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index 6cee085..dbea709 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -61,16 +61,7 @@ struct Record }; template -struct RecordArrayOf : ArrayOf > -{ - inline bool sanitize (SANITIZE_ARG_DEF, const char *base) { - if (!(SANITIZE (this->len) && SANITIZE_GET_SIZE())) return false; - unsigned int count = this->len; - for (unsigned int i = 0; i < count; i++) - if (!SANITIZE_THIS (this->array[i])) - return false; - } -}; +struct RecordArrayOf : ArrayOf > {}; template struct RecordListOf : RecordArrayOf