Skip to main content

malloc_counter.hpp File

Included Headers​

#include <stdlib.h>

Typedefs Index​

usingmalloc_count_callback_type = void(void *cookie, size_t current)

Functions Index​

size_tmalloc_count_current (void)
size_tmalloc_count_peak (void)
voidmalloc_count_reset_peak (void)
size_tmalloc_count_num_allocs (void)
voidmalloc_count_set_callback (malloc_count_callback_type *cb, void *cookie)
voidmalloc_count_print_status (void)
voidmalloc_count_start_monitoring (void)
voidmalloc_count_stop_monitoring (void)
size_tmalloc_count_thread_allocs (void)

Macro Definitions Index​

#defineEXPECT_N_MALLOCS(statement, n_mallocs)   ...
#defineEXPECT_NO_MALLOC(statement)   EXPECT_N_MALLOCS(statement, 0)

Typedefs​

malloc_count_callback_type​

using malloc_count_callback_type = void(void* cookie, size_t current)

Definition at line 61 of file malloc_counter.hpp.

Functions​

malloc_count_current()​

size_t malloc_count_current (void)

Declaration at line 49 of file malloc_counter.hpp, definition at line 91 of file malloc_counter.cpp.

malloc_count_num_allocs()​

size_t malloc_count_num_allocs (void)

Declaration at line 58 of file malloc_counter.hpp, definition at line 106 of file malloc_counter.cpp.

malloc_count_peak()​

size_t malloc_count_peak (void)

Declaration at line 52 of file malloc_counter.hpp, definition at line 96 of file malloc_counter.cpp.

malloc_count_print_status()​

void malloc_count_print_status (void)

Declaration at line 69 of file malloc_counter.hpp, definition at line 111 of file malloc_counter.cpp.

malloc_count_reset_peak()​

void malloc_count_reset_peak (void)

Declaration at line 55 of file malloc_counter.hpp, definition at line 101 of file malloc_counter.cpp.

malloc_count_set_callback()​

void malloc_count_set_callback (malloc_count_callback_type * cb, void * cookie)

Declaration at line 66 of file malloc_counter.hpp, definition at line 116 of file malloc_counter.cpp.

malloc_count_start_monitoring()​

void malloc_count_start_monitoring (void)

Declaration at line 72 of file malloc_counter.hpp, definition at line 122 of file malloc_counter.cpp.

malloc_count_stop_monitoring()​

void malloc_count_stop_monitoring (void)

Declaration at line 75 of file malloc_counter.hpp, definition at line 134 of file malloc_counter.cpp.

malloc_count_thread_allocs()​

size_t malloc_count_thread_allocs (void)

Declaration at line 78 of file malloc_counter.hpp, definition at line 139 of file malloc_counter.cpp.

Macro Definitions​

EXPECT_N_MALLOCS​

#define EXPECT_N_MALLOCS(statement, n_mallocs)   ...
Value
  malloc_count_start_monitoring(); \   statement; \   do \   { \     const size_t total_allocations = malloc_count_thread_allocs(); \     malloc_count_stop_monitoring(); \     EXPECT_EQ(static_cast<int>(total_allocations), n_mallocs) \         << "Expected " << n_mallocs << " allocations, but found " << total_allocations << " calls to operator new"; \   } while (0)

Definition at line 88 of file malloc_counter.hpp.

EXPECT_NO_MALLOC​

#define EXPECT_NO_MALLOC(statement)   EXPECT_N_MALLOCS(statement, 0)

Definition at line 100 of file malloc_counter.hpp.


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.