LCOV - code coverage report
Current view: top level - ext/amrex/3d-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      403505 :     DataAllocator ()  noexcept  = default;
      13             : 
      14        3315 :     DataAllocator (Arena* ar) noexcept : m_arena(ar) {}
      15             : 
      16        3315 :     [[nodiscard]] void* alloc (std::size_t sz) const noexcept {
      17        3315 :         return arena()->alloc(sz);
      18             :     }
      19             : 
      20      409456 :     void free (void* pt) const noexcept {
      21      409456 :         arena()->free(pt);
      22      409456 :     }
      23             : 
      24      412771 :     [[nodiscard]] Arena* arena () const noexcept {
      25      412771 :         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