1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/memmodel/epoc/flexible/mmu/mcleanup.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,54 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @internalComponent
1.22 +*/
1.23 +
1.24 +#ifndef MCLEANUP_H
1.25 +#define MCLEANUP_H
1.26 +
1.27 +
1.28 +typedef void (*TMemoryCleanupCallback)(TAny*);
1.29 +
1.30 +class TMemoryCleanup
1.31 + {
1.32 +public:
1.33 + void Add(TMemoryCleanupCallback aCallback, TAny* aArg);
1.34 + static void Cleanup(TAny* aDummy=0);
1.35 + static void Init2();
1.36 +
1.37 + FORCE_INLINE TMemoryCleanup()
1.38 + : iCallback(0)
1.39 + {}
1.40 +
1.41 + FORCE_INLINE ~TMemoryCleanup()
1.42 + {
1.43 + __NK_ASSERT_DEBUG(iCallback==0);
1.44 + // This 'generic' cleanup API isn't safe in the situation where an object
1.45 + // being cleaned up is deleted. This is currently not a problem because
1.46 + // we only use this for permanent objects, but to help prevent future bugs
1.47 + // assert that this object is never deleted...
1.48 + __NK_ASSERT_ALWAYS(0);
1.49 + }
1.50 +private:
1.51 + TMemoryCleanup* iNext;
1.52 + TMemoryCleanupCallback iCallback;
1.53 + TAny* iArg;
1.54 + };
1.55 +
1.56 +
1.57 +#endif