Browse Source

Use malloc/strdup instead of Alloc.

master
Reece H. Dunn 9 years ago
parent
commit
bbd981efb8

+ 4
- 1
src/libespeak-ng/dictionary.c View File

return 1; 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); size = fread(tr->data_dictlist, 1, size, f);
fclose(f); fclose(f);



+ 0
- 12
src/libespeak-ng/speech.c View File

return statbuf.st_size; 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) ESPEAK_NG_API void espeak_ng_InitializePath(const char *path)
{ {
if (path != NULL) { if (path != NULL) {

+ 0
- 1
src/libespeak-ng/speech.h View File



extern ESPEAK_NG_API void strncpy0(char *to, const char *from, int size); extern ESPEAK_NG_API void strncpy0(char *to, const char *from, int size);
extern ESPEAK_NG_API int GetFileLength(const char *filename); extern ESPEAK_NG_API int GetFileLength(const char *filename);
char *Alloc(int size);


#ifdef __cplusplus #ifdef __cplusplus
} }

+ 2
- 5
src/libespeak-ng/synthdata.c View File

if (*ptr != NULL) if (*ptr != NULL)
free(*ptr); free(*ptr);


if ((*ptr = Alloc(length)) == NULL) { if ((*ptr = malloc(length)) == NULL) {
fclose(f_in); fclose(f_in);
return ENOMEM; return ENOMEM;
} }
FILE *f; FILE *f;
int ix; int ix;
char c1; char c1;
char *p;
char string[200]; char string[200];


for (ix = 0; ix < N_SOUNDICON_SLOTS; ix++) { for (ix = 0; ix < N_SOUNDICON_SLOTS; ix++) {
ix = sscanf(&buf[10], "_%c %s", &c1, string); ix = sscanf(&buf[10], "_%c %s", &c1, string);
if (ix == 2) { if (ix == 2) {
soundicon_tab[n_soundicon_tab].name = c1; soundicon_tab[n_soundicon_tab].name = c1;
p = Alloc(strlen(string)+1); soundicon_tab[n_soundicon_tab].filename = strdup(string);
strcpy(p, string);
soundicon_tab[n_soundicon_tab].filename = p;
soundicon_tab[n_soundicon_tab++].length = 0; soundicon_tab[n_soundicon_tab++].length = 0;
} }
} }

+ 1
- 2
src/libespeak-ng/tr_languages.c View File

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 0, 56, 0, 57, 0, // 0x170 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 0, 56, 0, 57, 0, // 0x170
}; };


tr = (Translator *)Alloc(sizeof(Translator)); if ((tr = (Translator *)malloc(sizeof(Translator))) == NULL)
if (tr == NULL)
return NULL; return NULL;


tr->charset_a0 = charsets[1]; // ISO-8859-1, this is for when the input is not utf8 tr->charset_a0 = charsets[1]; // ISO-8859-1, this is for when the input is not utf8

Loading…
Cancel
Save