sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: sl@0: #ifndef MCLEANUP_H sl@0: #define MCLEANUP_H sl@0: sl@0: sl@0: typedef void (*TMemoryCleanupCallback)(TAny*); sl@0: sl@0: class TMemoryCleanup sl@0: { sl@0: public: sl@0: void Add(TMemoryCleanupCallback aCallback, TAny* aArg); sl@0: static void Cleanup(TAny* aDummy=0); sl@0: static void Init2(); sl@0: sl@0: FORCE_INLINE TMemoryCleanup() sl@0: : iCallback(0) sl@0: {} sl@0: sl@0: FORCE_INLINE ~TMemoryCleanup() sl@0: { sl@0: __NK_ASSERT_DEBUG(iCallback==0); sl@0: // This 'generic' cleanup API isn't safe in the situation where an object sl@0: // being cleaned up is deleted. This is currently not a problem because sl@0: // we only use this for permanent objects, but to help prevent future bugs sl@0: // assert that this object is never deleted... sl@0: __NK_ASSERT_ALWAYS(0); sl@0: } sl@0: private: sl@0: TMemoryCleanup* iNext; sl@0: TMemoryCleanupCallback iCallback; sl@0: TAny* iArg; sl@0: }; sl@0: sl@0: sl@0: #endif