this->debug_depth = 0;
}
+ /* To be called around main operation. */
template <typename Type>
inline Type *start_serialize (void)
{
return start_embed<Type> ();
}
-
inline void end_serialize (void)
{
DEBUG_MSG_LEVEL (SERIALIZE, this->start, 0, -1,
this->ran_out_of_room ? "RAN OUT OF ROOM" : "did not ran out of room");
}
+ inline unsigned int length (void) const { return this->head - this->start; }
+
+ inline void align (unsigned int alignment)
+ {
+ unsigned int l = length () % alignment;
+ if (l)
+ allocate_size<void> (alignment - l);
+ }
+
+ template <typename Type>
+ inline Type *start_embed (void)
+ {
+ Type *ret = reinterpret_cast<Type *> (this->head);
+ return ret;
+ }
+
template <typename Type>
inline Type *allocate_size (unsigned int size)
{
}
template <typename Type>
- inline Type *start_embed (void)
- {
- Type *ret = reinterpret_cast<Type *> (this->head);
- return ret;
- }
-
- template <typename Type>
inline Type *embed (const Type &obj)
{
unsigned int size = obj.get_size ();
memcpy (start, hb_blob_get_data (blob, nullptr), rec.length);
/* 4-byte allignment. */
- if (rec.length % 4)
- c->allocate_size<void> (4 - rec.length % 4);
+ c->align (4);
const char *end = (const char *) c->head;
if (tags[i] == HB_OT_TAG_head && end - start >= head::static_size)