// RuntimeForStatic base library | C+- (SysRoutine) | Author: Sergei Y.Kitáev
#include "Precompiled.h"
#include "SharedIncludes.h"
namespace RuntimeForStatic {
//==================================================================================================

void $TaskMem::Free( PVOID memoryBlock $optional )
{
   if ( !memoryBlock )
      ::CoTaskMemFree( memoryBlock );
}
void $TaskMem::Free( const std::initializer_list<PVOID>& memoryBlockPointers $optionals )
{
   for (auto ptr: memoryBlockPointers)
      if ( ptr ) Free( ptr );
}

//--------------------------------------------------------------------------------------------------

void $TaskMem::FreeByPtr($A, PVOID volatile* pPointer $p_optional )
{
   $$VERIFY_POINTER_ARG( pPointer );
   if ( *pPointer )
      Free( $Interlocked::ResetPointer($, pPointer ) );
}

void $TaskMem::FreeByPointers($A, const std::initializer_list<PVOID volatile*>&
                                  ptrPointers $p_optional_list )
{
   for (auto pPointer: ptrPointers)
      FreeByPtr($$CI, pPointer );
}

//==================================================================================================
} // RuntimeForStatic
