[pango/harfbuzz-ng: 41/57] [HB] Simplify indirect sanitize()
- From: Behdad Esfahbod <behdad src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [pango/harfbuzz-ng: 41/57] [HB] Simplify indirect sanitize()
- Date: Tue, 4 Aug 2009 20:04:48 +0000 (UTC)
commit a501ac401398cc85d2c9695bb2fc41dc4f7efb39
Author: Behdad Esfahbod <behdad behdad org>
Date: Tue Aug 4 10:23:01 2009 -0400
[HB] Simplify indirect sanitize()
pango/opentype/hb-open-types-private.hh | 52 ++++++++++++-------------
pango/opentype/hb-ot-layout-common-private.hh | 11 +-----
2 files changed, 26 insertions(+), 37 deletions(-)
---
diff --git a/pango/opentype/hb-open-types-private.hh b/pango/opentype/hb-open-types-private.hh
index b3d7541..198c0ad 100644
--- a/pango/opentype/hb-open-types-private.hh
+++ b/pango/opentype/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 <typename Type>
-struct OffsetArrayOf : ArrayOf<OffsetTo<Type> > {
- 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<OffsetTo<Type> > {};
/* Array of LongOffset's */
template <typename Type>
-struct LongOffsetArrayOf : ArrayOf<LongOffsetTo<Type> > {
- 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<LongOffsetTo<Type> > {};
/* LongArray of LongOffset's */
template <typename Type>
-struct LongOffsetLongArrayOf : LongArrayOf<LongOffsetTo<Type> > {
- 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<LongOffsetTo<Type> > {};
+
/* 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/pango/opentype/hb-ot-layout-common-private.hh b/pango/opentype/hb-ot-layout-common-private.hh
index a6fa2b4..72c2db0 100644
--- a/pango/opentype/hb-ot-layout-common-private.hh
+++ b/pango/opentype/hb-ot-layout-common-private.hh
@@ -61,16 +61,7 @@ struct Record
};
template <typename Type>
-struct RecordArrayOf : ArrayOf<Record<Type> >
-{
- 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<Record<Type> > {};
template <typename Type>
struct RecordListOf : RecordArrayOf<Type>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]