X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/5963ec5bc27cc5ce1ff3e6a60d0776de87c4f250..98735bfe852adb9e5421e5c04bb2e0119af443bd:/Pooling.hpp?ds=sidebyside diff --git a/Pooling.hpp b/Pooling.hpp index 24c7cc2..e3116d9 100644 --- a/Pooling.hpp +++ b/Pooling.hpp @@ -62,6 +62,11 @@ class CYPool { return (size + 7) & ~0x3; } + template + static void delete_(void *data) { + reinterpret_cast(data)->~Type_(); + } + CYPool(const CYPool &); public: @@ -182,6 +187,13 @@ class CYPool { } void atexit(void (*code)(void *), void *data = NULL); + + template + Type_ &object() { + Type_ *value(new(*this) Type_()); + atexit(&delete_, value); + return *value; + } }; _finline void *operator new(size_t size, CYPool &pool) {