From 4a446ac35136eff23d55f47bdd7b40095ad707ab Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 4 May 2010 22:46:21 -0400 Subject: [PATCH] Use function template for pass-thru argument --- src/hb-open-type-private.hh | 26 ++++++-------------------- src/hb-ot-layout-gpos-private.hh | 6 +++--- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index a240fdb0f..72dd3c8db 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -451,15 +451,8 @@ struct GenericOffsetTo : OffsetType Type &obj = StructAtOffset (*CharP(base), offset); return likely (obj.sanitize (SANITIZE_ARG)) || neuter (SANITIZE_ARG); } - inline bool sanitize (SANITIZE_ARG_DEF, void *base, void *base2) { - TRACE_SANITIZE (); - if (!SANITIZE_SELF ()) return false; - unsigned int offset = *this; - if (unlikely (!offset)) return true; - Type &obj = StructAtOffset (*CharP(base), offset); - return likely (obj.sanitize (SANITIZE_ARG, base2)) || neuter (SANITIZE_ARG); - } - inline bool sanitize (SANITIZE_ARG_DEF, void *base, unsigned int user_data) { + template + inline bool sanitize (SANITIZE_ARG_DEF, void *base, T user_data) { TRACE_SANITIZE (); if (!SANITIZE_SELF ()) return false; unsigned int offset = *this; @@ -544,16 +537,8 @@ struct GenericArrayOf return false; return true; } - inline bool sanitize (SANITIZE_ARG_DEF, void *base, void *base2) { - TRACE_SANITIZE (); - if (!likely (sanitize_shallow (SANITIZE_ARG))) return false; - unsigned int count = len; - for (unsigned int i = 0; i < count; i++) - if (!array()[i].sanitize (SANITIZE_ARG, base, base2)) - return false; - return true; - } - inline bool sanitize (SANITIZE_ARG_DEF, void *base, unsigned int user_data) { + template + inline bool sanitize (SANITIZE_ARG_DEF, void *base, T user_data) { TRACE_SANITIZE (); if (!likely (sanitize_shallow (SANITIZE_ARG))) return false; unsigned int count = len; @@ -608,7 +593,8 @@ struct OffsetListOf : OffsetArrayOf TRACE_SANITIZE (); return OffsetArrayOf::sanitize (SANITIZE_ARG, CharP(this)); } - inline bool sanitize (SANITIZE_ARG_DEF, unsigned int user_data) { + template + inline bool sanitize (SANITIZE_ARG_DEF, T user_data) { TRACE_SANITIZE (); return OffsetArrayOf::sanitize (SANITIZE_ARG, CharP(this), user_data); } diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh index 5f3875186..9837c0493 100644 --- a/src/hb-ot-layout-gpos-private.hh +++ b/src/hb-ot-layout-gpos-private.hh @@ -1076,7 +1076,7 @@ struct MarkBasePosFormat1 && SANITIZE_WITH_BASE (this, markCoverage) && SANITIZE_WITH_BASE (this, baseCoverage) && SANITIZE_WITH_BASE (this, markArray) - && likely (baseArray.sanitize (SANITIZE_ARG, CharP(this), classCount)); + && likely (baseArray.sanitize (SANITIZE_ARG, CharP(this), (unsigned int) classCount)); } private: @@ -1200,7 +1200,7 @@ struct MarkLigPosFormat1 && SANITIZE_WITH_BASE (this, markCoverage) && SANITIZE_WITH_BASE (this, ligatureCoverage) && SANITIZE_WITH_BASE (this, markArray) - && likely (ligatureArray.sanitize (SANITIZE_ARG, CharP(this), classCount)); + && likely (ligatureArray.sanitize (SANITIZE_ARG, CharP(this), (unsigned int) classCount)); } private: @@ -1303,7 +1303,7 @@ struct MarkMarkPosFormat1 && SANITIZE_WITH_BASE (this, mark1Coverage) && SANITIZE_WITH_BASE (this, mark2Coverage) && SANITIZE_WITH_BASE (this, mark1Array) - && likely (mark2Array.sanitize (SANITIZE_ARG, CharP(this), classCount)); + && likely (mark2Array.sanitize (SANITIZE_ARG, CharP(this), (unsigned int) classCount)); } private: