ATLAS Offline Software
Loading...
Searching...
No Matches
leakcheck.h File Reference

Pitifully simple leak checker for unit tests. Just verifies that allocations/deallocations match over an RAII region. More...

#include <malloc.h>
#include <unordered_set>
#include <iostream>
#include <cassert>
Include dependency graph for leakcheck.h:

Go to the source code of this file.

Classes

struct  Athena_test::LeakCheckDisable
struct  Athena_test::Leakcheck

Namespaces

namespace  Athena_test
 functions & macros to test the difference between floats

Functions

void * newImpl (std::size_t size)
void * operator new (std::size_t size)
void deleteImpl (void *ptr) noexcept
void operator delete (void *ptr) noexcept
void operator delete (void *ptr, size_t) noexcept

Variables

std::unordered_set< void * > * Athena_test::allocs = nullptr

Detailed Description

Pitifully simple leak checker for unit tests. Just verifies that allocations/deallocations match over an RAII region.

Author
scott snyder snyde.nosp@m.r@bn.nosp@m.l.gov
Date
Nov, 2016

Overrides the standard new/delete functions, so should not be #included from any code that would be included in a library.

Definition in file leakcheck.h.

Function Documentation

◆ deleteImpl()

void deleteImpl ( void * ptr)
noexcept

Definition at line 81 of file leakcheck.h.

82{
85 disable.erase(ptr);
86 }
87 free(ptr);
88}
std::unordered_set< void * > * allocs
Definition leakcheck.h:51

◆ newImpl()

void * newImpl ( std::size_t size)

Definition at line 65 of file leakcheck.h.

66{
67 void* ptr = malloc(size);
70 disable.insert(ptr);
71 }
72 return ptr;
73}
void * ptr(T *p)
Definition SGImplSvc.cxx:74

◆ operator delete() [1/2]

void operator delete ( void * ptr)
noexcept

Definition at line 90 of file leakcheck.h.

91{
92 deleteImpl(ptr);
93}
void deleteImpl(void *ptr) noexcept
Definition leakcheck.h:81

◆ operator delete() [2/2]

void operator delete ( void * ptr,
size_t  )
noexcept

Definition at line 95 of file leakcheck.h.

96{
97 deleteImpl(ptr);
98}

◆ operator new()

void * operator new ( std::size_t size)

Definition at line 75 of file leakcheck.h.

75 {
76 return newImpl(size);
77}
void * newImpl(std::size_t size)
Definition leakcheck.h:65