X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/5999c31517bb72b55257d25f482edc566adec045..fb98ac0c3231f2685211b3120fd3dc315c056d37:/Pooling.hpp diff --git a/Pooling.hpp b/Pooling.hpp index 86f57ca..73f1c80 100644 --- a/Pooling.hpp +++ b/Pooling.hpp @@ -20,13 +20,17 @@ class CYPool { public: CYPool() { - apr_pool_create(&pool_, NULL); + _aprcall(apr_pool_create(&pool_, NULL)); } ~CYPool() { apr_pool_destroy(pool_); } + void Clear() { + apr_pool_clear(pool_); + } + operator apr_pool_t *() const { return pool_; } @@ -40,4 +44,28 @@ class CYPool { } }; +struct CYData { + apr_pool_t *pool_; + + virtual ~CYData() { + } + + static void *operator new(size_t size, apr_pool_t *pool) { + void *data(apr_palloc(pool, size)); + reinterpret_cast(data)->pool_ = pool; + return data; + } + + static void *operator new(size_t size) { + apr_pool_t *pool; + _aprcall(apr_pool_create(&pool, NULL)); + return operator new(size, pool); + } + + static void operator delete(void *data) { + apr_pool_destroy(reinterpret_cast(data)->pool_); + } + +}; + #endif/*CYPOOLING_HPP*/