44
|
1 |
//
|
|
2 |
// * Copyright 2004 Neusoft America Inc.
|
|
3 |
// * All rights reserved.
|
|
4 |
// * This component and the accompanying materials are made available
|
|
5 |
// * under the terms of the Eclipse Public License v1.0
|
|
6 |
// * which accompanies this distribution, and is available
|
|
7 |
// * at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
// *
|
|
9 |
// * Contributors:
|
|
10 |
// * Keith Collins (Neusoft America Inc.) original software development and additional code and modifications.
|
|
11 |
// * Thomas Gahagen (Neusoft America Inc.) additional code and modifications.
|
|
12 |
// * Zhen Yuan (Neusoft America Inc.) additional code and modifications.
|
|
13 |
// *
|
|
14 |
// * Description: This file defines a tool for putting a name to the class
|
|
15 |
// * when a memory leak occurs, you can trace it back by looking
|
|
16 |
// at the memory space.
|
|
17 |
//
|
|
18 |
|
|
19 |
// etools.h
|
|
20 |
|
|
21 |
/** @file etools.h
|
|
22 |
*
|
|
23 |
*/
|
|
24 |
|
|
25 |
#ifndef ETOOLS_H__
|
|
26 |
#define ETOOLS_H__
|
|
27 |
|
|
28 |
#include <e32std.h>
|
|
29 |
#include <e32panic.h>
|
|
30 |
#include <e32svr.h>
|
|
31 |
|
|
32 |
// Tool for putting a name to the class
|
|
33 |
// when a memory leak occurs, you can trace it back
|
|
34 |
// by looking at the memory space!
|
|
35 |
// the for(;;) is a bit awkward
|
|
36 |
#define CLASSNAMEDECL(a) char __iName[sizeof(#a)];
|
|
37 |
|
|
38 |
#ifdef _DEBUG
|
|
39 |
#define CLASSNAMEINIT(a) \
|
|
40 |
char tmp[] = #a; \
|
|
41 |
for(TUint _i_##a=0;_i_##a<sizeof(tmp);_i_##a++) __iName[_i_##a] = tmp[_i_##a];
|
|
42 |
#define CLASSNAME this->__iName
|
|
43 |
#else
|
|
44 |
#define CLASSNAMEINIT(a)
|
|
45 |
#define CLASSNAME "?"
|
|
46 |
#endif
|
|
47 |
|
|
48 |
//
|
|
49 |
// put this in your constructor/destructor to see the memory usage
|
|
50 |
//
|
|
51 |
#if defined __DEBUGLOGFILE__
|
|
52 |
#define CTOR(a) \
|
|
53 |
_LOGF4("+++ object created at 0x%08x (%d bytes)\t%s ", this, sizeof(a) - __Align8(sizeof(__iName)), #a );
|
|
54 |
#define DTOR(a) \
|
|
55 |
_LOGF4("--- object deleted at 0x%08x (%d bytes)\t%s", this, sizeof(a) - (4+(sizeof(__iName) & ~0x03)), #a );
|
|
56 |
#else
|
|
57 |
#define CTOR(a)
|
|
58 |
#define DTOR(a)
|
|
59 |
#endif
|
|
60 |
|
|
61 |
//
|
|
62 |
// size of arrays
|
|
63 |
//
|
|
64 |
|
|
65 |
#ifndef ELEM_SIZE
|
|
66 |
#define ELEM_SIZE(t) (sizeof(t)/sizeof(t[0]))
|
|
67 |
#endif
|
|
68 |
|
|
69 |
#endif // ETOOLS_H__
|