no non è corretto, perché nel caso la WriteFile lanci un'eccezione, chBuf non viene deallocata. Cmq in C++ è meglio usare new/delete, piuttosto che malloc/free.Originariamente inviato da Giovanni Pr88
Ragazzi, in questo pezzo del mio codice ho deallocato l'array chBuf nel seguente modo utilizzando free(chBuf)
è corretto?!codice:char tmp1[]="cd VocaleConsole2.0\ncd Exe\ncd Profiles\ncd "; char tmp2[]="\ncd test\nHCopy -A -D -T 1 -C wav_config -S codetrain.scp\njulian -input rawfile -filelist wavlst -smpFreq 48000 -C ../../../SrcScripts/create_model_scripts/julian.jconf > juliusOutput\n./ProcessJuliusOutput.pl juliusOutput juliusProcessed\nHResults -I testref.mlf tiedlist juliusProcessed \n"; length = sizeof(tmp1)+sizeof(tmp2)+sizeof(nome_cognome); char *chBuf=(char *) malloc(length); strcpy (chBuf,tmp1); strcat (chBuf,nome_cognome); strcat (chBuf, tmp2); bSuccess = WriteFile(Child_IN_Wr, chBuf,length, &dwWritten, NULL); free (chBuf);
Un saluto
Giovanni