Beispiel #1
0
 /**
  * Frees the given block and resets it.
  * \param b Block to be freed.
  */
 void deallocate(block &b)
 {
   if (b) {
     ::free(b.ptr);
     b.reset();
   }
 }
      /**
       * Frees the given block back to the system. The block gets nulled.
       * \param b The block, describing what memory shall be freed.
       */
      void deallocate(block &b) noexcept
      {
        if (b) {
#ifdef _MSC_VER
          _aligned_free(b.ptr);
#else
          ::free(b.ptr);
#endif
          b.reset();
        }
      }
 /**
  * The given block gets deallocated. If Prefix or Sufix are defined then
  * their d'tor(s) are called.
  * \param b The Block that should be freed. 
  */
 void deallocate(block &b) noexcept
 {
   if (!b) {
     return;
   }
   if (prefix_size > 0) {
     outerToPrefix(b)->~Prefix();
   }
   if (sufix_size > 0) {
     outerToSufix(b)->~Sufix();
   }
   auto innerBlock(toInnerBlock(b));
   _allocator.deallocate(innerBlock);
   b.reset();
 }
 /**
  * The given block gets deallocated. If Prefix or Sufix are defined then
  * their d'tor(s) are called.
  * \param b The Block that should be freed.
  */
 void deallocate(block &b) noexcept
 {
   if (!b) {
     return;
   }
   if (prefix_size > 0) {
     outer_to_prefix(b)->~Prefix();
   }
   if (sufix_size > 0) {
     outer_to_sufix(b)->~Sufix();
   }
   auto innerBlock(to_inner_block(b));
   allocator_.deallocate(innerBlock);
   b.reset();
 }
    void deallocate(block &b) noexcept
    {
      if (!b) {
        return;
      }
      if (!owns(b)) {
        assert(false);
        return;
      }

      // If it was the most recent allocated MemoryBlock, then we can re-use the
      // memory. Otherwise this freed MemoryBlock is not available for further
      // allocations. Since all happens on the stack this is not a leak!
      if (isLastUsedBlock(b)) {
        _p = static_cast<char *>(b.ptr);
      }
      b.reset();
    }