Browse Source

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

master
Reece Dunn 13 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

@@ -1192,6 +1192,7 @@ ESPEAK_API espeak_ERROR espeak_Synchronize(void)


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

ESPEAK_API espeak_ERROR espeak_Terminate(void)
{//===========================================
@@ -1214,6 +1215,7 @@ ESPEAK_API espeak_ERROR espeak_Terminate(void)
Free(outbuf);
outbuf = NULL;
FreePhData();
FreeVoiceList();

if(f_logespeak)
{

+ 13
- 7
src/voices.cpp View File

@@ -1744,6 +1744,18 @@ espeak_ERROR SetVoiceByProperties(espeak_VOICE *voice_selector)
return(EE_OK);
} // 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;
}



@@ -1763,13 +1775,7 @@ ESPEAK_API const espeak_VOICE **espeak_ListVoices(espeak_VOICE *voice_spec)
char path_voices[sizeof(path_home)+12];

// 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);
len_path_voices = strlen(path_voices)+1;

Loading…
Cancel
Save