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

This commit is contained in:
Reece Dunn
2011-09-01 07:31:46 +01:00
parent 53661a6551
commit 09b470c871
2 changed files with 15 additions and 7 deletions
+2
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
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;