0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
/**
|
|
17 |
@file
|
|
18 |
@internalComponent
|
|
19 |
*/
|
|
20 |
|
|
21 |
#ifndef MCLEANUP_H
|
|
22 |
#define MCLEANUP_H
|
|
23 |
|
|
24 |
|
|
25 |
typedef void (*TMemoryCleanupCallback)(TAny*);
|
|
26 |
|
|
27 |
class TMemoryCleanup
|
|
28 |
{
|
|
29 |
public:
|
|
30 |
void Add(TMemoryCleanupCallback aCallback, TAny* aArg);
|
|
31 |
static void Cleanup(TAny* aDummy=0);
|
|
32 |
static void Init2();
|
|
33 |
|
|
34 |
FORCE_INLINE TMemoryCleanup()
|
|
35 |
: iCallback(0)
|
|
36 |
{}
|
|
37 |
|
|
38 |
FORCE_INLINE ~TMemoryCleanup()
|
|
39 |
{
|
|
40 |
__NK_ASSERT_DEBUG(iCallback==0);
|
|
41 |
// This 'generic' cleanup API isn't safe in the situation where an object
|
|
42 |
// being cleaned up is deleted. This is currently not a problem because
|
|
43 |
// we only use this for permanent objects, but to help prevent future bugs
|
|
44 |
// assert that this object is never deleted...
|
|
45 |
__NK_ASSERT_ALWAYS(0);
|
|
46 |
}
|
|
47 |
private:
|
|
48 |
TMemoryCleanup* iNext;
|
|
49 |
TMemoryCleanupCallback iCallback;
|
|
50 |
TAny* iArg;
|
|
51 |
};
|
|
52 |
|
|
53 |
|
|
54 |
#endif
|