#ifndef __MYU_STANDARD_LIBRARY__mslcommon_H__
#define __MYU_STANDARD_LIBRARY__mslcommon_H__

#include <stdio.h>
#include <memory.h>

//	NULLだったら開放しないdelete
#define SAFE_DELETE(p)				if ( p != NULL ) { delete p; p=NULL; }
#define SAFE_DELETE_ARY(p)			if ( p != NULL ) { delete []p; p=NULL; }	//	配列バージョン
#define SAFE_DELETE_ARRAY(p)		if ( p != NULL ) { delete []p; p=NULL; }	//	配列バージョン
#define SAFE_DELETE_TYPE(TYPE,p)	if ( p != NULL ) { delete (TYPE*)p; p=NULL; }

template <typename T> void SafeDefineTmpl(T *p) {
	if ( *p != NULL ) { delete *p; *p=NULL; }
}
#define SAFE_DELETE_TMPL(TYPE,PTR)  SafeDefineTmpl<TYPE*>((TYPE**)&PTR)
//#define SAFE_DELETE_t SAFE_DELETE_TMPL

#define NSMSL_START	namespace msl{
#define NSMSL_END	}

#define MslZeroMemory(DEST,LEN)		memset((DEST),0,(LEN))
#define MslZeroMemoryAS(DEST)		MslZeroMemory(DEST,sizeof(DEST))
#define ZeroMemoryAS(DEST)			MslZeroMemory(DEST,sizeof(DEST))

#define reverse_bool(B)		{ if(B){B=false;}else{B=true;} }

#endif//__MYU_STANDARD_LIBRARY__mslcommon_H__
