mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-10-31 05:35:35 +00:00
Use malloc/strdup instead of Alloc.
This commit is contained in:
@@ -231,7 +231,10 @@ int LoadDictionary(Translator *tr, const char *name, int no_error)
|
||||
return 1;
|
||||
}
|
||||
|
||||
tr->data_dictlist = Alloc(size);
|
||||
if ((tr->data_dictlist = malloc(size)) == NULL) {
|
||||
fclose(f);
|
||||
return 3;
|
||||
}
|
||||
size = fread(tr->data_dictlist, 1, size, f);
|
||||
fclose(f);
|
||||
|
||||
|
||||
@@ -251,18 +251,6 @@ int GetFileLength(const char *filename)
|
||||
return statbuf.st_size;
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
char *Alloc(int size)
|
||||
{
|
||||
char *p;
|
||||
if ((p = (char *)malloc(size)) == NULL)
|
||||
fprintf(stderr, "Can't allocate memory\n"); // I was told that size+1 fixes a crash on 64-bit systems
|
||||
return p;
|
||||
}
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
ESPEAK_NG_API void espeak_ng_InitializePath(const char *path)
|
||||
{
|
||||
if (path != NULL) {
|
||||
|
||||
@@ -69,7 +69,6 @@ extern char path_home[N_PATH_HOME]; // this is the espeak-data directory
|
||||
|
||||
extern ESPEAK_NG_API void strncpy0(char *to, const char *from, int size);
|
||||
extern ESPEAK_NG_API int GetFileLength(const char *filename);
|
||||
char *Alloc(int size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ static espeak_ng_STATUS ReadPhFile(void **ptr, const char *fname, int *size, esp
|
||||
if (*ptr != NULL)
|
||||
free(*ptr);
|
||||
|
||||
if ((*ptr = Alloc(length)) == NULL) {
|
||||
if ((*ptr = malloc(length)) == NULL) {
|
||||
fclose(f_in);
|
||||
return ENOMEM;
|
||||
}
|
||||
@@ -411,7 +411,6 @@ void LoadConfig(void)
|
||||
FILE *f;
|
||||
int ix;
|
||||
char c1;
|
||||
char *p;
|
||||
char string[200];
|
||||
|
||||
for (ix = 0; ix < N_SOUNDICON_SLOTS; ix++) {
|
||||
@@ -434,9 +433,7 @@ void LoadConfig(void)
|
||||
ix = sscanf(&buf[10], "_%c %s", &c1, string);
|
||||
if (ix == 2) {
|
||||
soundicon_tab[n_soundicon_tab].name = c1;
|
||||
p = Alloc(strlen(string)+1);
|
||||
strcpy(p, string);
|
||||
soundicon_tab[n_soundicon_tab].filename = p;
|
||||
soundicon_tab[n_soundicon_tab].filename = strdup(string);
|
||||
soundicon_tab[n_soundicon_tab++].length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,8 +220,7 @@ static Translator *NewTranslator(void)
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 0, 56, 0, 57, 0, // 0x170
|
||||
};
|
||||
|
||||
tr = (Translator *)Alloc(sizeof(Translator));
|
||||
if (tr == NULL)
|
||||
if ((tr = (Translator *)malloc(sizeof(Translator))) == NULL)
|
||||
return NULL;
|
||||
|
||||
tr->charset_a0 = charsets[1]; // ISO-8859-1, this is for when the input is not utf8
|
||||
|
||||
Reference in New Issue
Block a user