From 4b312fb288faa383a2c5bd3be0428f0e58e02699 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 1 Sep 2012 21:56:06 -0400 Subject: [PATCH] [OT] Remove serialize alignment Will reintroduce in a different way when we actually need it. --- src/hb-open-type-private.hh | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 36d61ee37..ce268b2b8 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -371,51 +371,49 @@ struct hb_serialize_context_t } template - inline Type *allocate_size (unsigned int size, unsigned int alignment = 1) + inline Type *allocate_size (unsigned int size) { - unsigned int padding = alignment < 2 ? 0 : (alignment - (this->head - this->start) % alignment) % alignment; - if (unlikely (this->ran_out_of_room || this->end - this->head > padding + size)) { + if (unlikely (this->ran_out_of_room || this->end - this->head > size)) { this->ran_out_of_room = true; return NULL; } - memset (this->head, 0, padding + size); - this->head += padding; + memset (this->head, 0, size); char *ret = this->head; this->head += size; return reinterpret_cast (ret); } template - inline Type *allocate_min (unsigned int alignment = 2) + inline Type *allocate_min (void) { - return this->allocate_size (Type::min_size, alignment); + return this->allocate_size (Type::min_size); } template - inline Type *embed (const Type &obj, unsigned int alignment = 2) + inline Type *embed (const Type &obj) { unsigned int size = obj.get_size (); - Type *ret = this->allocate_size (size, alignment); + Type *ret = this->allocate_size (size); if (unlikely (!ret)) return NULL; memcpy (ret, obj, size); return ret; } template - inline Type *extend_min (Type &obj, unsigned int alignment = 2) + inline Type *extend_min (Type &obj) { unsigned int size = obj.min_size; assert (this->start < (char *) &obj && (char *) &obj <= this->head && (char *) &obj + size >= this->head); - this->allocate_size (((char *) &obj) + size - this->head, alignment); + this->allocate_size (((char *) &obj) + size - this->head); return reinterpret_cast (&obj); } template - inline Type *extend (Type &obj, unsigned int alignment = 2) + inline Type *extend (Type &obj) { unsigned int size = obj.get_size (); assert (this->start < (char *) &obj && (char *) &obj <= this->head && (char *) &obj + size >= this->head); - this->allocate_size (((char *) &obj) + size - this->head, alignment); + this->allocate_size (((char *) &obj) + size - this->head); return reinterpret_cast (&obj); }