diff --git a/src/RS232_win.c b/src/RS232_win.c --- a/src/RS232_win.c +++ b/src/RS232_win.c @@ -120,10 +120,10 @@ rs232port_t rs232open(char* psPortName) rs232port_t fd; /* Char to Wchar conversion*/ int neededSize = MultiByteToWideChar(CP_ACP, 0, psPortName, -1, 0, 0); - wchar_t* wcstr = new wchar_t[neededSize]; - MultiByteToWideChar(CP_ACP, 0, charString, -1, wcstr, neededSize); + wchar_t* wcstr = (wchar_t*)malloc(sizeof(wchar_t)*neededSize); + MultiByteToWideChar(CP_ACP, 0, psPortName, -1, wcstr, neededSize); fd = (rs232port_t)CreateFile(wcstr,GENERIC_READ | GENERIC_WRITE,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0); - delete wcstr; + free(wcstr); #ifdef RS232_debug if(fd==(rs232port_t)INVALID_HANDLE_VALUE) {