Browse Source

ensure that the memory allocated by espeak_ListVoices is cleaned up on exit.

master
Reece Dunn 14 years ago
parent
commit
09b470c871
2 changed files with 15 additions and 7 deletions
  1. 2
    0
      src/speak_lib.cpp
  2. 13
    7
      src/voices.cpp

+ 2
- 0
src/speak_lib.cpp View File





extern void FreePhData(void); extern void FreePhData(void);
extern void FreeVoiceList(void);


ESPEAK_API espeak_ERROR espeak_Terminate(void) ESPEAK_API espeak_ERROR espeak_Terminate(void)
{//=========================================== {//===========================================
Free(outbuf); Free(outbuf);
outbuf = NULL; outbuf = NULL;
FreePhData(); FreePhData();
FreeVoiceList();


if(f_logespeak) if(f_logespeak)
{ {

+ 13
- 7
src/voices.cpp View File

return(EE_OK); return(EE_OK);
} // end of SetVoiceByProperties } // end of SetVoiceByProperties


void FreeVoiceList()
{
for(int ix=0; ix<n_voices_list; ix++)
{
if(voices_list[ix] != NULL)
{
free(voices_list[ix]);
voices_list[ix] = NULL;
}
}
n_voices_list = 0;
}






char path_voices[sizeof(path_home)+12]; char path_voices[sizeof(path_home)+12];


// free previous voice list data // free previous voice list data

for(ix=0; ix<n_voices_list; ix++)
{
if(voices_list[ix] != NULL)
free(voices_list[ix]);
}
n_voices_list = 0;
FreeVoiceList();


sprintf(path_voices,"%s%cvoices",path_home,PATHSEP); sprintf(path_voices,"%s%cvoices",path_home,PATHSEP);
len_path_voices = strlen(path_voices)+1; len_path_voices = strlen(path_voices)+1;

Loading…
Cancel
Save