Changed typing in GrowingPool. It is more C++ like
authorBenjamin Segovia <segovia.benjamin@gmail.com>
Fri, 17 Feb 2012 08:46:52 +0000 (08:46 +0000)
committerKeith Packard <keithp@keithp.com>
Fri, 10 Aug 2012 23:15:20 +0000 (16:15 -0700)
backend/src/ir/function.hpp
backend/src/sys/alloc.hpp

index 2c1d02a..2fbb59f 100644 (file)
@@ -81,7 +81,7 @@ namespace ir {
     }
     /*! Allocate a new instruction (with the growing pool) */
     INLINE Instruction *newInstruction(void) {
-      return insnPool.allocate();
+      return new (insnPool.allocate()) Instruction();
     }
     /*! Deallocate an instruction (with the growing pool) */
     INLINE void deleteInstruction(Instruction *insn) {
index ed1e346..ae54ed0 100644 (file)
@@ -189,9 +189,9 @@ namespace gbe
   public:
     GrowingPool(void) : current(GBE_NEW(GrowingPoolElem, 1)), freeList(NULL) {}
     ~GrowingPool(void) { GBE_ASSERT(current); GBE_DELETE(current); }
-    T *allocate(void) {
+    void *allocate(void) {
       if (this->freeList != NULL) {
-        T *data = (T*) freeList;
+        void *data = (void*) freeList;
         this->freeList = *(void**) freeList;
         return data;
       }
@@ -200,10 +200,10 @@ namespace gbe
         elem->next = current;
         current = elem;
       }
-      T *data = current->data + current->allocated++;
+      void *data = (T*) current->data + current->allocated++;
       return data;
     }
-    void deallocate(T *t) {
+    void deallocate(void *t) {
       if (t == NULL) return;
       *(void**) t = this->freeList;
       this->freeList = t;