MemoryLeakIndicator
Loading...
Searching...
No Matches
MilDebugNew.h File Reference

Header for overloaded new and delete operator. More...

#include <new>

Go to the source code of this file.

Macros

#define DEBUG_NEW   new( __FILE__, __LINE__ )
 Redefinition of the operator new.
 
#define new   DEBUG_NEW
 Redefinition of the operator new.
 

Functions

void * debug_new (std::size_t size, const char *fileName, int line)
 
void * operator new (std::size_t size, const char *fileName, int line)
 
void * operator new[] (std::size_t size, const char *fileName, int line)
 
void debug_delete (void *ptr)
 
void operator delete (void *ptr)
 
void operator delete (void *, const char *, int)
 

Detailed Description

Header for overloaded new and delete operator.

Author
Helmut Jakoby

Terms of License

This file is part of the MemoryLeakIndicator module.

MemoryLeakIndicator is free software:

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

GNU Affero General Public License Usage
You can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. Please review the following information to ensure the GNU Affero General Public License requirements will be met: https://www.gnu.org/licenses/agpl-3.0.en.html .

Macro Definition Documentation

◆ DEBUG_NEW

#define DEBUG_NEW   new( __FILE__, __LINE__ )

Redefinition of the operator new.

◆ new

#define new   DEBUG_NEW

Redefinition of the operator new.

Function Documentation

◆ debug_delete()

void debug_delete ( void * ptr)

Passed object will be deregistered in MemSpy::LeakMap when MemSpy::LeakMap instantiates and then removed from memory.

Parameters
[in]ptrPointer to the object to be deleted.

◆ debug_new()

void * debug_new ( std::size_t size,
const char * fileName,
int line )

An object is instantiated and registered in MemSpy::LeakMap if MemSpy::LeakMap is instantiated. param[in] size The size of the object to instantiate. param[in] fileName The file name where 'new' was called. param[in] line The line number where 'new' was called.

Returns
The newly instantiated object.

◆ operator delete() [1/2]

void operator delete ( void * ,
const char * ,
int  )

This operator delete is not called, but is intended to suppress the following warning: warning C4291: 'void * operator new(size_t,const char *,int)': no matching operator delete found; memory will not be freed if initialization throws an exception

◆ operator delete() [2/2]

void operator delete ( void * ptr)

This operator delete deletes and deregisters an object in MemSpy::LeakMap when MemSpy::LeakMap instantiates.

Parameters
[in]ptrPointer to the object to be deleted.

◆ operator new()

void * operator new ( std::size_t size,
const char * fileName,
int line )

This operator new registers a new object in MemSpy::LeakMap via function debug_new (...) when MemSpy::LeakMap is instantiated. param[in] size The size of the object to instantiate. param[in] fileName The file name where 'new' was called. param[in] line The line number where 'new' was called.

Returns
The newly instantiated object.

◆ operator new[]()

void * operator new[] ( std::size_t size,
const char * fileName,
int line )