change code to use allocMem wrapper for memory allocation

One of the new string handling routines is a wrapper for allocating
memory. This commit changes the rest of the code to take advantage of
that wrapper.
This commit is contained in:
William Hubbs 2011-05-06 23:08:33 -05:00
commit 3b4b6d0cbc
3 changed files with 10 additions and 22 deletions

View file

@ -45,11 +45,7 @@ static void queue_add_cmd(enum command_t cmd, enum adjust_t adj, int value)
struct espeak_entry_t *entry;
int added = 0;
entry = malloc(sizeof(struct espeak_entry_t));
if (!entry) {
perror("unable to allocate memory for queue entry");
return;
}
entry = allocMem(sizeof(struct espeak_entry_t));
entry->cmd = cmd;
entry->adjust = adj;
entry->value = value;
@ -67,11 +63,7 @@ static void queue_add_text(char *txt, size_t length)
struct espeak_entry_t *entry;
int added = 0;
entry = malloc(sizeof(struct espeak_entry_t));
if (!entry) {
perror("unable to allocate memory for queue entry");
return;
}
entry = allocMem(sizeof(struct espeak_entry_t));
entry->cmd = CMD_SPEAK_TEXT;
entry->adjust = ADJ_SET;
entry->buf = strdup(txt);