Add LTTngUSTLogger logger plugin test
[deliverable/titan.core.git] / common / dbgnew.hh
1 /******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Balasko, Jeno
10 * Raduly, Csaba
11 *
12 ******************************************************************************/
13 #ifndef DBGNEW_HH
14 #define DBGNEW_HH
15
16 #ifndef _Common_memory_H
17 #include "memory.h"
18 #endif
19
20 #include <new>
21
22 #ifdef MEMORY_DEBUG
23
24 class debug_new_counter_t
25 {
26 static int count;
27 static const char * progname;
28 public:
29 debug_new_counter_t();
30 ~debug_new_counter_t();
31 void set_program_name(const char *pgn);
32 };
33 // implementation in new.cc
34
35 // An instance for every translation unit. Because each instance is constructed
36 // before main() and probably before any other global object,
37 // it is destroyed after main() ends and all global objects are destroyed.
38 // The last destructor runs check_mem_leak().
39 static debug_new_counter_t debug_new_counter;
40
41 // Custom placement new for memory tracking
42 void* operator new(size_t size, const char* file, int line);
43 void* operator new[](size_t size, const char* file, int line);
44
45 // TODO: these might be GCC version dependant
46 void* operator new(size_t size, const std::nothrow_t&, const char* file, int line);
47 void* operator new[](size_t size, const std::nothrow_t&, const char* file, int line);
48
49 inline void* operator new(size_t, void* __p, const char*, int) { return __p; }
50 inline void* operator new[](size_t, void* __p, const char*, int) { return __p; }
51
52 // Redirect "normal" new to memory-tracking placement new.
53 #define new(...) new(__VA_ARGS__, __FILE__, __LINE__)
54
55 #endif // MEMORY_DEBUG
56
57 #endif
This page took 0.032366 seconds and 5 git commands to generate.