COM.MoveMemory(newPtr, buffer, byteCount);
COM.MoveMemory(newPtr, chars, byteCount);
public void javaToNative (Object object, TransferData transferData){	transferData.result = COM.E_FAIL;	if (object == null || !(object instanceof String)) return;	String string = (String)object;	if (string.length() == 0) return;	if (!isSupportedType(transferData)) {		// did not match the TYMED		transferData.stgmedium = new STGMEDIUM();		transferData.result = COM.DV_E_TYMED;		return;	}	switch (transferData.type) {		case COM.CF_UNICODETEXT: {			TCHAR buffer = new TCHAR(0, string, true);			int byteCount = buffer.length() * TCHAR.sizeof;			int newPtr = COM.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, byteCount);			COM.MoveMemory(newPtr, buffer, byteCount);				transferData.stgmedium = new STGMEDIUM();			transferData.stgmedium.tymed = COM.TYMED_HGLOBAL;			transferData.stgmedium.unionField = newPtr;			transferData.stgmedium.pUnkForRelease = 0;			transferData.result = COM.S_OK;			break;		}		case COM.CF_TEXT: {			int count = string.length();			char[] chars = new char[count + 1];			string.getChars(0, count, chars, 0);			int cchMultiByte = COM.WideCharToMultiByte(CodePage, 0, chars, -1, null, 0, null, null);			if (cchMultiByte == 0) {				transferData.stgmedium = new STGMEDIUM();				transferData.result = COM.DV_E_STGMEDIUM;				return;			}			int lpMultiByteStr = COM.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, cchMultiByte);			COM.WideCharToMultiByte(CodePage, 0, chars, -1, lpMultiByteStr, cchMultiByte, null, null);			transferData.stgmedium = new STGMEDIUM();			transferData.stgmedium.tymed = COM.TYMED_HGLOBAL;			transferData.stgmedium.unionField = lpMultiByteStr;			transferData.stgmedium.pUnkForRelease = 0;			transferData.result = COM.S_OK;			break;		}	}	return;}