/usr/include/CppUTest/MemoryLeakWarningPlugin.h is in libcpputest-dev 3.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | /*
* Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef D_MemoryLeakWarningPlugin_h
#define D_MemoryLeakWarningPlugin_h
#include "TestPlugin.h"
///////////////////////////////////////////////////////////////////////////////
//
// MemoryLeakWarning.h
//
// MemoryLeakWarning defines the inteface to a platform specific
// memory leak detection class. See Platforms directory for examples
//
///////////////////////////////////////////////////////////////////////////////
#define IGNORE_ALL_LEAKS_IN_TEST() MemoryLeakWarningPlugin::getFirstPlugin()->ignoreAllLeaksInTest();
#define EXPECT_N_LEAKS(n) MemoryLeakWarningPlugin::getFirstPlugin()->expectLeaksInTest(n);
#if CPPUTEST_USE_MEM_LEAK_DETECTION
#undef new
#if CPPUTEST_USE_STD_CPP_LIB
#include <new>
void* operator new(size_t size) throw(std::bad_alloc);
void* operator new[](size_t size) throw(std::bad_alloc);
void* operator new(size_t size, const std::nothrow_t&) throw();
void* operator new[](size_t size, const std::nothrow_t&) throw();
#else
void* operator new(size_t size);
void* operator new[](size_t size);
#endif
void operator delete(void* mem) throw();
void operator delete[](void* mem) throw();
void operator delete(void* mem, const char* file, int line) throw();
void operator delete[](void* mem, const char* file, int line) throw();
#if CPPUTEST_USE_NEW_MACROS
#include "MemoryLeakDetectorNewMacros.h"
#endif
#endif
extern void crash_on_allocation_number(unsigned alloc_number);
class MemoryLeakDetector;
class MemoryLeakFailure;
class MemoryLeakWarningPlugin: public TestPlugin
{
public:
MemoryLeakWarningPlugin(const SimpleString& name,
MemoryLeakDetector* localDetector = 0);
virtual ~MemoryLeakWarningPlugin();
virtual void preTestAction(UtestShell& test, TestResult& result);
virtual void postTestAction(UtestShell& test, TestResult& result);
virtual const char* FinalReport(int toBeDeletedLeaks = 0);
void ignoreAllLeaksInTest();
void expectLeaksInTest(int n);
void destroyGlobalDetectorAndTurnOffMemoryLeakDetectionInDestructor(bool des);
MemoryLeakDetector* getMemoryLeakDetector();
static MemoryLeakWarningPlugin* getFirstPlugin();
static MemoryLeakDetector* getGlobalDetector();
static MemoryLeakFailure* getGlobalFailureReporter();
static void setGlobalDetector(MemoryLeakDetector* detector, MemoryLeakFailure* reporter);
static void destroyGlobalDetector();
static void turnOffNewDeleteOverloads();
static void turnOnNewDeleteOverloads();
private:
MemoryLeakDetector* memLeakDetector_;
bool ignoreAllWarnings_;
bool destroyGlobalDetectorAndTurnOfMemoryLeakDetectionInDestructor_;
int expectedLeaks_;
int failureCount_;
static MemoryLeakWarningPlugin* firstPlugin_;
};
extern void* cpputest_malloc_location_with_leak_detection(size_t size, const char* file, int line);
extern void* cpputest_realloc_location_with_leak_detection(void* memory, size_t size, const char* file, int line);
extern void cpputest_free_location_with_leak_detection(void* buffer, const char* file, int line);
#endif
|