- Type_ *malloc(size_t size) {
- size = align(size);
-
- if (size > size_) {
- // XXX: is this an optimal malloc size?
- size_ = std::max<size_t>(size, size + align(sizeof(Cleaner)));
+ Type_ *malloc(size_t size, size_t alignment = CYAlignment) {
+ uint8_t *end(data_);
+ CYAlign(end, alignment);
+ end += size;
+
+ if (size_t(end - data_) > size_) {
+ size_t need(sizeof(Cleaner));
+ CYAlign(need, alignment);
+ need += size;
+ size_ = std::max<size_t>(next_, need);
+ next_ *= 2;