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
12 ******************************************************************************/
16 #ifndef _Common_memory_H
22 class debug_new_counter_t
25 static const char * progname;
27 debug_new_counter_t();
28 ~debug_new_counter_t();
29 void set_program_name(const char *pgn);
31 // implementation in new.cc
33 // An instance for every translation unit. Because each instance is constructed
34 // before main() and probably before any other global object,
35 // it is destroyed after main() ends and all global objects are destroyed.
36 // The last destructor runs check_mem_leak().
37 static debug_new_counter_t debug_new_counter;
39 // Custom placement new for memory tracking
40 void* operator new(size_t size, const char* file, int line);
41 void* operator new[](size_t size, const char* file, int line);
43 // Redirect "normal" new to memory-tracking placement new.
44 #define new new(__FILE__, __LINE__)
46 #endif // MEMORY_DEBUG