X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/5d5d70c083c2b891eb5382df084c90b0e2d406e5..aca28f9662f95e5a1835355830173624a300cd0c:/Pooling.hpp diff --git a/Pooling.hpp b/Pooling.hpp index 6225392..c03dd1d 100644 --- a/Pooling.hpp +++ b/Pooling.hpp @@ -43,6 +43,7 @@ class CYPool { private: uint8_t *data_; size_t size_; + size_t next_; struct Cleaner { Cleaner *next_; @@ -70,9 +71,10 @@ class CYPool { CYPool(const CYPool &); public: - CYPool() : + CYPool(size_t next = 64) : data_(NULL), size_(0), + next_(next), cleaner_(NULL) { } @@ -90,8 +92,8 @@ class CYPool { size = align(size); if (size > size_) { - // XXX: is this an optimal malloc size? - size_ = std::max(size, size + align(sizeof(Cleaner))); + size_ = std::max(next_, size + align(sizeof(Cleaner))); + next_ *= 2; data_ = reinterpret_cast(::malloc(size_)); atexit(free, data_); _assert(size <= size_);