void free ()
{ ::free ((void *) arrayZ); arrayZ = nullptr; length = 0; }
+ template <typename hb_serialize_context_t>
+ hb_array_t copy (hb_serialize_context_t *c) const
+ {
+ TRACE_SERIALIZE (this);
+ auto* out = c->template start_embed (arrayZ);
+ if (unlikely (!c->extend_size (out, get_size ()))) return_trace (hb_array_t ());
+ for (unsigned i = 0; i < length; i++)
+ out[i] = arrayZ[i]; /* TODO: add version that calls c->copy() */
+ return_trace (hb_array_t (out, length));
+ }
+
template <typename hb_sanitize_context_t>
bool sanitize (hb_sanitize_context_t *c) const
{ return c->check_array (arrayZ, length); }
{
TRACE_SERIALIZE (this);
auto *out = c->start_embed (this);
- if (unlikely (!out->serialize (c, count))) return_trace (nullptr);
- for (unsigned i = 0; i < count; i++)
- out->arrayZ[i] = arrayZ[i]; /* TODO: add version that calls c->copy() */
+ if (unlikely (!as_array (count).copy (c))) return_trace (nullptr);
return_trace (out);
}
TRACE_SERIALIZE (this);
auto *out = c->start_embed (this);
unsigned count = len;
- if (unlikely (!out->serialize (c, count))) return_trace (nullptr);
- for (unsigned i = 0; i < count; i++)
- out->arrayZ[i] = arrayZ[i]; /* TODO: add version that calls c->copy() */
+ if (unlikely (!c->extend_min (out))) return_trace (nullptr);
+ c->check_assign (out->len, len);
+ if (unlikely (!as_array ().copy (c))) return_trace (nullptr);
return_trace (out);
}
allocate_size<void> (alignment - l);
}
- template <typename Type>
+ template <typename Type = void>
Type *start_embed (const Type *obj HB_UNUSED = nullptr) const
{ return reinterpret_cast<Type *> (this->head); }
template <typename Type>