Browse Source

Properly clean up the open files in CompilePhonemeData2.

master
Reece H. Dunn 9 years ago
parent
commit
2c446ecba3
1 changed files with 17 additions and 5 deletions
  1. 17
    5
      src/libespeak-ng/compiledata.c

+ 17
- 5
src/libespeak-ng/compiledata.c View File



free(list); free(list);
list = NULL; list = NULL;
fclose(f_report);
} }


static void error(const char *format, ...) static void error(const char *format, ...)


sprintf(fname, "%s/../phsource/%s", path_home, "compile_report"); sprintf(fname, "%s/../phsource/%s", path_home, "compile_report");
f_report = fopen_log(f_errors, fname, "w"); f_report = fopen_log(f_errors, fname, "w");

if (f_report == NULL) {
int error = errno;
fclose(f_in);
return create_file_error_context(context, error, fname);
}


sprintf(fname, "%s/%s", path_home, "phondata-manifest"); sprintf(fname, "%s/%s", path_home, "phondata-manifest");
if ((f_phcontents = fopen_log(f_phcontents, fname, "w")) == NULL) if ((f_phcontents = fopen_log(f_phcontents, fname, "w")) == NULL)
if (f_phdata == NULL) { if (f_phdata == NULL) {
int error = errno; int error = errno;
fclose(f_in); fclose(f_in);
fclose(f_report);
fclose(f_phcontents);
return create_file_error_context(context, errno, fname); return create_file_error_context(context, errno, fname);
} }


if (f_phindex == NULL) { if (f_phindex == NULL) {
int error = errno; int error = errno;
fclose(f_in); fclose(f_in);
fclose(f_report);
fclose(f_phcontents);
fclose(f_phdata); fclose(f_phdata);
return create_file_error_context(context, errno, fname); return create_file_error_context(context, errno, fname);
} }
if (f_phtab == NULL) { if (f_phtab == NULL) {
int error = errno; int error = errno;
fclose(f_in); fclose(f_in);
fclose(f_report);
fclose(f_phcontents);
fclose(f_phdata); fclose(f_phdata);
fclose(f_phindex); fclose(f_phindex);
return create_file_error_context(context, errno, fname); return create_file_error_context(context, errno, fname);
WritePhonemeTables(); WritePhonemeTables();


fprintf(f_errors, "\nRefs %d, Reused %d\n", count_references, duplicate_references); fprintf(f_errors, "\nRefs %d, Reused %d\n", count_references, duplicate_references);

fclose(f_in); fclose(f_in);
fclose(f_phcontents);
fclose(f_phdata); fclose(f_phdata);
if (f_prog_log != NULL)
fclose(f_prog_log);
fclose(f_phindex); fclose(f_phindex);
fclose(f_phtab); fclose(f_phtab);
fclose(f_phcontents);
if (f_prog_log != NULL)
fclose(f_prog_log);


LoadPhData(NULL, NULL); LoadPhData(NULL, NULL);


CompileReport(); CompileReport();


fclose(f_report);

if (resample_count > 0) { if (resample_count > 0) {
fprintf(f_errors, "\n%d WAV files resampled to %d Hz\n", resample_count, samplerate_native); fprintf(f_errors, "\n%d WAV files resampled to %d Hz\n", resample_count, samplerate_native);
fprintf(log, "Compiled phonemes: %d errors, %d files resampled to %d Hz.\n", error_count, resample_count, samplerate_native); fprintf(log, "Compiled phonemes: %d errors, %d files resampled to %d Hz.\n", error_count, resample_count, samplerate_native);

Loading…
Cancel
Save