Common Regoin for Access Protection. Like the NullPool, but writable.
#ifndef HB_NO_VISIBILITY
const void * const _hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
+void * _hb_CrapPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
#endif
void cbdt_callback (const uint8_t* data, unsigned int length,
#ifndef HB_NO_VISIBILITY
const void * const _hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
+void * _hb_CrapPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
#endif
template <typename Type, int Bytes> struct LEInt;
}
inline Type& operator [] (unsigned int i)
{
+ if (unlikely (i >= len)) return Crap(Type);
return arrayZ[i];
}
inline unsigned int get_size (void) const
if (unlikely (i >= this->len)) return Null(Type);
return this+this->arrayZ[i];
}
+ inline const Type& operator [] (unsigned int i)
+ {
+ if (unlikely (i >= this->len)) return Crap(Type);
+ return this+this->arrayZ[i];
+ }
inline bool sanitize (hb_sanitize_context_t *c) const
{
if (unlikely (i >= len || !i)) return Null(Type);
return arrayZ[i-1];
}
+ inline Type& operator [] (unsigned int i)
+ {
+ if (unlikely (i >= len || !i)) return Crap(Type);
+ return arrayZ[i-1];
+ }
inline unsigned int get_size (void) const
{ return len.static_size + (len ? len - 1 : 0) * Type::static_size; }
#ifndef HB_NO_VISIBILITY
const void * const _hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
+void * _hb_CrapPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
#endif
*/
/*
- * Null objects
+ * Static pools
*/
/* Global nul-content Null pool. Enlarge as necessary. */
= {}
#endif
;
-
/* Generic nul-content Null objects. */
template <typename Type>
static inline const Type& Null (void) {
static_assert (Namespace::Type::min_size + 1 <= sizeof (_Null##Type), "Null pool too small. Enlarge.")
+/* Global writable pool. Enlarge as necessary. */
+
+#ifdef HB_NO_VISIBILITY
+static
+#else
+extern HB_INTERNAL
+#endif
+void * _hb_CrapPool[HB_NULL_POOL_SIZE / sizeof (void *)]
+#ifdef HB_NO_VISIBILITY
+= {}
+#endif
+;
+/* CRAP pool: Common Region for Access Protection. */
+template <typename Type>
+static inline Type& Crap (void) {
+ static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE.");
+ Type *obj = reinterpret_cast<Type *> (_hb_CrapPool);
+ *obj = Null(Type);
+ return *obj;
+}
+#define Crap(Type) Crap<Type>()
+
/* arrays and maps */
arrayZ = static_array;
}
- inline Type& operator [] (unsigned int i) { return arrayZ[i]; }
- inline const Type& operator [] (unsigned int i) const { return arrayZ[i]; }
+ inline Type& operator [] (unsigned int i)
+ {
+ if (unlikely (i >= len))
+ return Crap (Type);
+ return arrayZ[i];
+ }
+ inline const Type& operator [] (unsigned int i) const
+ {
+ if (unlikely (i >= len))
+ return Null (Type);
+ return arrayZ[i];
+ }
inline Type *push (void)
{
#if !defined(HB_NO_VISIBILITY) && !defined(HB_SUBSET_BUILTIN)
const void * const _hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
+void * _hb_CrapPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
#endif
#ifndef HB_NO_VISIBILITY
const void * const _hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
+void * _hb_CrapPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
#endif
int