LCOV - code coverage report
Current view: top level - ext/amrex/2d-coverage-g++-24.08/include - AMReX_DataAllocator.H (source / functions) Hit Total Coverage
Test: coverage_merged.info Lines: 9 9 100.0 %
Date: 2024-11-18 05:28:54 Functions: 5 5 100.0 %

          Line data    Source code
       1             : #ifndef AMREX_DATA_ALLOCATOR_H_
       2             : #define AMREX_DATA_ALLOCATOR_H_
       3             : #include <AMReX_Config.H>
       4             : 
       5             : #include <AMReX_Arena.H>
       6             : 
       7             : namespace amrex {
       8             : 
       9             : struct DataAllocator {
      10             :     Arena* m_arena = nullptr;
      11             : 
      12      886192 :     DataAllocator ()  noexcept  = default;
      13             : 
      14        5171 :     DataAllocator (Arena* ar) noexcept : m_arena(ar) {}
      15             : 
      16        5171 :     [[nodiscard]] void* alloc (std::size_t sz) const noexcept {
      17        5171 :         return arena()->alloc(sz);
      18             :     }
      19             : 
      20     3419810 :     void free (void* pt) const noexcept {
      21     3419810 :         arena()->free(pt);
      22     3419810 :     }
      23             : 
      24     3424980 :     [[nodiscard]] Arena* arena () const noexcept {
      25     3424980 :         return (m_arena) ? m_arena : The_Arena();
      26             :     }
      27             : };
      28             : 
      29             : struct DataDeleter {
      30             :     Arena* m_arena = nullptr;
      31             :     DataDeleter () noexcept  = default;
      32             :     DataDeleter (Arena* ar) noexcept : m_arena(ar) {}
      33             :     [[nodiscard]] Arena* arena () const noexcept { return (m_arena) ? m_arena : The_Arena(); }
      34             :     void operator() (void* pt) const noexcept { arena()->free(pt); }
      35             : };
      36             : 
      37             : }
      38             : 
      39             : #endif

Generated by: LCOV version 1.14