Mjolnir Core
Core functionality of the Mjolnir API
Public Member Functions | Static Public Member Functions | List of all members
NewDeleteCounter Class Reference

Counts the number of new and delete calls since the instance was created. More...

#include <new_delete_counter.h>

Public Member Functions

 NewDeleteCounter (const NewDeleteCounter &)=delete
 
 NewDeleteCounter (NewDeleteCounter &&)=delete
 
auto get_num_delete_calls () const noexcept -> I32
 Gets the number of delete calls since the construction of the instance. More...
 
auto get_num_new_calls () const noexcept -> I32
 Gets the number of new calls since the construction of the instance. More...
 
auto operator= (const NewDeleteCounter &) -> NewDeleteCounter &=delete
 
auto operator= (NewDeleteCounter &&) -> NewDeleteCounter &=delete
 
void print_num_calls () const noexcept
 Prints the number of new and delete calls since the construction of the class instance.
 

Static Public Member Functions

static auto get_total_num_delete_calls () noexcept -> I32
 Gets the total number of delete calls of the program. More...
 
static auto get_total_num_new_calls () noexcept -> I32
 Gets the total number of new calls of the program. More...
 

Detailed Description

Counts the number of new and delete calls since the instance was created.

This header overrides the default implementations of new and delete and should only be used in tests.

Remarks
The necessary overloads of new and delete interfere with valgrind and other tools that override those operators. Define DISABLE_NEW_DELETE_COUNTER if you like to run them on files that include this class.