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

template<typename T>static T* $task_mem::Free( T*& pElements $optional ) $ret_null
{
   if ( pElements )
   {
      $TaskMem::Free( pElements );
      pElements = nullptr;
   }
   return nullptr;
}
template<typename T>static T* $task_mem::Free( const std::initializer_list<T*&>&
                                               listOfPointers $optionals ) $ret_null
{
   for (auto ptr: listOfPointers)
   {
      $TaskMem::Free( ptr );
      ptr = nullptr;
   }
   return nullptr;
}

template<typename T>static T* $task_mem::FreeByPtr( T* volatile* ppElements $optional ) $ret_null
{
   $$VERIFY_POINTER_ARG( ppElements );
   return $TaskMem::Free($, (PVOID volatile*)ppElements );
}
template<typename T>static T* $task_mem::FreeByPointers( const std::initializer_list<T* volatile*>&
                                                         listOfPtrPointers $optionals ) $ret_null
{
   for (auto ppElements: listOfPtrPointers)
   {
      $$VERIFY_POINTER_ARG( ppElements );
      $TaskMem::Free($, (PVOID volatile*)ppElements );
   }
   return nullptr;
}

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