]> git.saurik.com Git - cycript.git/blobdiff - Pooling.hpp
Made drastic changes to the serializer in order to support correctly serializing...
[cycript.git] / Pooling.hpp
index 86f57caa26cdc29a5340a9c68d97fa4944cb38b9..73f1c805fe8620ec1c79e04679558440566ef926 100644 (file)
@@ -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<CYData *>(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<CYData *>(data)->pool_);
+    }
+
+};
+
 #endif/*CYPOOLING_HPP*/