mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-01 21:58:52 +00:00
ensure that the memory allocated by espeak_ListVoices is cleaned up on exit.
This commit is contained in:
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user