From: Jay Freeman (saurik) Date: Thu, 26 Nov 2015 10:02:28 +0000 (-0800) Subject: CYPool's reservation policy was a stub/mistake :/. X-Git-Tag: v0.9.590~276 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/caab73699bc789d99183e3af596ef8eaea8b5769 CYPool's reservation policy was a stub/mistake :/. --- 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_);