Use function template for pass-thru argument

This commit is contained in:
Behdad Esfahbod 2010-05-04 22:46:21 -04:00
parent 98daaf183d
commit 4a446ac351
2 changed files with 9 additions and 23 deletions

View File

@ -451,15 +451,8 @@ struct GenericOffsetTo : OffsetType
Type &obj = StructAtOffset<Type> (*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<Type> (*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 <typename T>
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 <typename T>
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<Type>
TRACE_SANITIZE ();
return OffsetArrayOf<Type>::sanitize (SANITIZE_ARG, CharP(this));
}
inline bool sanitize (SANITIZE_ARG_DEF, unsigned int user_data) {
template <typename T>
inline bool sanitize (SANITIZE_ARG_DEF, T user_data) {
TRACE_SANITIZE ();
return OffsetArrayOf<Type>::sanitize (SANITIZE_ARG, CharP(this), user_data);
}

View File

@ -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: