/****************************************************************************************************

		IShMemoryUtilities.h
		Copyright: (c) 2001 Eovia Corp. All rights reserved.

		Author:	Arnaud
		Date:	3/17/2005

****************************************************************************************************/

#ifndef __IShMemoryUtilities__
#define __IShMemoryUtilities__

#if CP_PRAGMA_ONCE
#pragma once
#endif


#include "MCCompObj.h"


MCDEFINE_GUID_H(IID_IShMemoryUtilities);


/// \addtogroup Utilities
/// \{

/// Memory utilities.  You should not need to use any of these functions.
struct IShMemoryUtilities: public IMCUnknown
{
public:
	virtual void*	 MCCOMAPI Malloc					(uint32  size) = 0;
	virtual void*	 MCCOMAPI Calloc					(uint32 nmemb, uint32 size) = 0;
	virtual void*	 MCCOMAPI Realloc					(void* ptr, uint32  size) = 0;
	virtual MCCOMErr MCCOMAPI Free						(void* ptr) = 0;
	virtual void*	 MCCOMAPI MCnew						(uint32  size) = 0;
	virtual MCCOMErr MCCOMAPI MCdelete					(void* ptr) = 0;
	virtual void*	 MCCOMAPI MCnewArray				(uint32  size) = 0;
	virtual MCCOMErr MCCOMAPI MCdeleteArray				(void* ptr) = 0;

 	virtual void*	 MCCOMAPI MallocAligned				(uint32 size, uint8 alignPower) = 0;
 	virtual MCCOMErr MCCOMAPI FreeAligned				(void* ptr) = 0;

	//11/11/98 Arnaud : Do NOT call ShPreparePhysicalMemory (temporary fix for kwak)
	virtual boolean  MCCOMAPI ShPreparePhysicalMemory	(uint32 &in_outMinumumLockable, uint32 &in_outMaximum) = 0;
	virtual void*	 MCCOMAPI MallocPhysical			(uint32 size) = 0;
	virtual void	 MCCOMAPI FreePhysical				(void *ptr, uint32 size) = 0;

	//06/02/02 Julien : memory alocation for PSHost plugins 
	virtual void*	 MCCOMAPI HighmallocPSHost			(int32  size) = 0;
	virtual MCCOMErr MCCOMAPI HighfreePSHost			(void* ptr) = 0;
	virtual void*	 MCCOMAPI HighlockPSHost			(void* ptr, boolean moveHigh)=0;
	virtual MCCOMErr MCCOMAPI HighunlockPSHost			(void* ptr)=0;
	virtual int32	 MCCOMAPI GetPIHandleSizePSHost		(void* ptr)=0;
	virtual int32	 MCCOMAPI SetPIHandleSizePSHost		(void* ptr, int32 newSize)=0;

#ifdef qLeaks
	// ****************************************************************************
	//								DisableLeakTracking
	// 
	// -Description:
	//
	// Temporarily disable the leak tracking
	//
	// -Returns: the previous state of leak tracking
	//
	virtual void*	 MCCOMAPI DisableLeakTracking()=0;

	// ****************************************************************************
	//								RestoreLeakTracking
	// 
	// -Description:
	//
	// Restore the state of leak tracking
	//
	// -Parameters:
	//
	// previousState	: the previous state returned by DisableLeakTracking
	//
	virtual void	 MCCOMAPI RestoreLeakTracking(void* previousState)=0;

#endif
};



/// \}




#endif
