Change to normal allocator
							parent
							
								
									8ca7773e50
								
							
						
					
					
						commit
						4f37ad3057
					
				| 
						 | 
				
			
			@ -89,12 +89,9 @@ public:
 | 
			
		|||
 | 
			
		||||
    /**
 | 
			
		||||
     * Create a duplicate object returned as a pointer to the generic Value interface.
 | 
			
		||||
     * For the sake of performance, this function use singleton pool allocator instead of the normal heap allocator.
 | 
			
		||||
     * The result must be deleted with Value::deallocate_, not with the 'delete' operator.
 | 
			
		||||
     */
 | 
			
		||||
    virtual Value* clone_() const {
 | 
			
		||||
      void *place = boost::singleton_pool<PoolTag, sizeof(GenericValue)>::malloc();
 | 
			
		||||
      GenericValue* ptr = new (place) GenericValue(*this); // calls copy constructor to fill in
 | 
			
		||||
      GenericValue* ptr = new GenericValue(*this); // calls copy constructor to fill in
 | 
			
		||||
      return ptr;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -102,8 +99,7 @@ public:
 | 
			
		|||
     * Destroy and deallocate this object, only if it was originally allocated using clone_().
 | 
			
		||||
     */
 | 
			
		||||
    virtual void deallocate_() const {
 | 
			
		||||
      this->~GenericValue(); // Virtual destructor cleans up the derived object
 | 
			
		||||
      boost::singleton_pool<PoolTag, sizeof(GenericValue)>::free((void*) this); // Release memory from pool
 | 
			
		||||
      delete this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			@ -118,10 +114,7 @@ public:
 | 
			
		|||
      // Call retract on the derived class using the retract trait function
 | 
			
		||||
      const T retractResult = traits<T>::Retract(GenericValue<T>::value(), delta);
 | 
			
		||||
 | 
			
		||||
      // Create a Value pointer copy of the result
 | 
			
		||||
      void* resultAsValuePlace =
 | 
			
		||||
          boost::singleton_pool<PoolTag, sizeof(GenericValue)>::malloc();
 | 
			
		||||
      Value* resultAsValue = new (resultAsValuePlace) GenericValue(retractResult);
 | 
			
		||||
      Value* resultAsValue = new GenericValue(retractResult);
 | 
			
		||||
 | 
			
		||||
      // Return the pointer to the Value base class
 | 
			
		||||
      return resultAsValue;
 | 
			
		||||
| 
						 | 
				
			
			@ -172,12 +165,6 @@ public:
 | 
			
		|||
      return *this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  private:
 | 
			
		||||
 | 
			
		||||
    /// Fake Tag struct for singleton pool allocator. In fact, it is never used!
 | 
			
		||||
    struct PoolTag {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
  private:
 | 
			
		||||
 | 
			
		||||
    /** Serialization function */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue