[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Convert src/modules to use GLib memory management exclusively.
From: |
Christopher Brannon |
Subject: |
[PATCH] Convert src/modules to use GLib memory management exclusively. |
Date: |
Thu, 23 Sep 2010 17:17:05 -0500 |
See the previous patch in this series for a justification of this
conversion.
This patch also removes xmalloc, xfree, and xrealloc, which are just
wrappers around libc's memory management routines.
---
src/modules/cicero.c | 10 ++--
src/modules/dummy.c | 12 ++--
src/modules/espeak.c | 22 +++---
src/modules/festival.c | 56 ++++++++--------
src/modules/festival_client.c | 39 ++++++------
src/modules/festival_client.h | 4 +-
src/modules/flite.c | 16 +++---
src/modules/generic.c | 70 ++++++++++----------
src/modules/ibmtts.c | 94 ++++++++++++++--------------
src/modules/ivona.c | 24 ++++----
src/modules/ivona_client.c | 16 +++---
src/modules/module_main.c | 14 ++--
src/modules/module_utils.c | 119 +++++++++++++----------------------
src/modules/module_utils.h | 37 +++++------
src/modules/module_utils_addvoice.c | 2 +-
15 files changed, 250 insertions(+), 285 deletions(-)
diff --git a/src/modules/cicero.c b/src/modules/cicero.c
index 1feff02..4ded306 100644
--- a/src/modules/cicero.c
+++ b/src/modules/cicero.c
@@ -203,7 +203,7 @@ module_init(char **status_info)
}
}
- cicero_message = malloc (sizeof (char*));
+ cicero_message = g_malloc (sizeof (char*));
*cicero_message = NULL;
cicero_semaphore = module_semaphore_init();
@@ -214,14 +214,14 @@ module_init(char **status_info)
if(ret != 0)
{
DBG("Cicero: thread failed\n");
- *status_info = strdup("The module couldn't initialize threads "
+ *status_info = g_strdup("The module couldn't initialize threads "
"This can be either an internal problem or an "
"architecture problem. If you are sure your
architecture "
"supports threads, please report a bug.");
return -1;
}
- *status_info = strdup("Cicero initialized succesfully.");
+ *status_info = g_strdup("Cicero initialized succesfully.");
return 0;
}
@@ -256,7 +256,7 @@ module_speak(gchar *data, size_t bytes, EMessageType
msgtype)
DBG("Requested data: |%s|\n", data);
if (*cicero_message != NULL){
- xfree(*cicero_message);
+ g_free(*cicero_message);
*cicero_message = NULL;
}
*cicero_message = module_strip_ssml(data);
@@ -312,7 +312,7 @@ module_close(int status)
if (module_terminate_thread(cicero_speaking_thread) != 0)
exit(1);
- /* xfree(cicero_voice); */
+ /* g_free(cicero_voice); */
exit(status);
}
diff --git a/src/modules/dummy.c b/src/modules/dummy.c
index 7c98745..58bb565 100644
--- a/src/modules/dummy.c
+++ b/src/modules/dummy.c
@@ -83,14 +83,14 @@ module_init(char **status_info)
ret = pthread_create(&dummy_speak_thread, NULL, _dummy_speak, NULL);
if(ret != 0){
DBG("Dummy: thread failed\n");
- *status_info = strdup("The module couldn't initialize threads"
+ *status_info = g_strdup("The module couldn't initialize threads"
"This can be either an internal problem or an"
"architecture problem. If you are sure your
architecture"
"supports threads, please report a bug.");
return -1;
}
- *status_info = strdup("Everything ok so far.");
+ *status_info = g_strdup("Everything ok so far.");
DBG("Ok, now debugging");
@@ -257,9 +257,9 @@ _dummy_child()
DBG("Entering child loop\n");
/* Read the waiting data */
- try1 = strdup("play "DATADIR"/dummy-message.wav > /dev/null 2> /dev/null");
- try2 = strdup("aplay "DATADIR"/dummy-message.wav > /dev/null 2> /dev/null");
- try3 = strdup("paplay "DATADIR"/dummy-message.wav > /dev/null 2> /dev/null");
+ try1 = g_strdup("play "DATADIR"/dummy-message.wav > /dev/null 2> /dev/null");
+ try2 = g_strdup("aplay "DATADIR"/dummy-message.wav > /dev/null 2>
/dev/null");
+ try3 = g_strdup("paplay "DATADIR"/dummy-message.wav > /dev/null 2>
/dev/null");
DBG("child: synth commands = |%s|%s|%s|", try1, try2, try3);
DBG("Speaking in child...");
@@ -283,7 +283,7 @@ _dummy_child()
module_sigunblockusr(&some_signals);
- xfree(try1); xfree(try2); xfree(try3);
+ g_free(try1); g_free(try2); g_free(try3);
DBG("Done, exiting from child.");
exit(0);
diff --git a/src/modules/espeak.c b/src/modules/espeak.c
index c81f5d4..8d0ddc0 100644
--- a/src/modules/espeak.c
+++ b/src/modules/espeak.c
@@ -266,7 +266,7 @@ module_init(char **status_info)
#endif
if (espeak_sample_rate == EE_INTERNAL_ERROR) {
DBG("Espeak: Could not initialize engine.");
- *status_info = strdup("Could not initialize engine. ");
+ *status_info = g_strdup("Could not initialize engine. ");
return FATAL_ERROR;
}
@@ -310,7 +310,7 @@ module_init(char **status_info)
ABORT("Failed to create playback thread.");
}
- *status_info = strdup("Espeak: Initialized successfully.");
+ *status_info = g_strdup("Espeak: Initialized successfully.");
return OK;
}
@@ -944,7 +944,7 @@ espeak_add_audio_to_playback_queue(short *audio_chunk, int
num_samples)
static gboolean
espeak_add_mark_to_playback_queue(const char *markId)
{
- TPlaybackQueueEntry *playback_queue_entry = (TPlaybackQueueEntry *)
xmalloc (sizeof (TPlaybackQueueEntry));
+ TPlaybackQueueEntry *playback_queue_entry = (TPlaybackQueueEntry *)
g_malloc (sizeof (TPlaybackQueueEntry));
playback_queue_entry->type = ESPEAK_QET_INDEX_MARK;
playback_queue_entry->data.markId = g_strdup(markId);
@@ -955,7 +955,7 @@ espeak_add_mark_to_playback_queue(const char *markId)
static gboolean
espeak_add_flag_to_playback_queue(EPlaybackQueueEntryType type)
{
- TPlaybackQueueEntry *playback_queue_entry = (TPlaybackQueueEntry *)
xmalloc (sizeof (TPlaybackQueueEntry));
+ TPlaybackQueueEntry *playback_queue_entry = (TPlaybackQueueEntry *)
g_malloc (sizeof (TPlaybackQueueEntry));
playback_queue_entry->type = type;
return playback_queue_push(playback_queue_entry);
@@ -965,7 +965,7 @@ espeak_add_flag_to_playback_queue(EPlaybackQueueEntryType
type)
static gboolean
espeak_add_sound_icon_to_playback_queue(const char* filename)
{
- TPlaybackQueueEntry *playback_queue_entry = (TPlaybackQueueEntry *)
xmalloc (sizeof (TPlaybackQueueEntry));
+ TPlaybackQueueEntry *playback_queue_entry = (TPlaybackQueueEntry *)
g_malloc (sizeof (TPlaybackQueueEntry));
playback_queue_entry->type = ESPEAK_QET_SOUND_ICON;
playback_queue_entry->data.sound_icon_filename = g_strdup(filename);
@@ -978,18 +978,18 @@ espeak_delete_playback_queue_entry(TPlaybackQueueEntry
*playback_queue_entry)
{
switch (playback_queue_entry->type) {
case ESPEAK_QET_AUDIO:
- xfree(playback_queue_entry->data.audio.audio_chunk);
+ g_free(playback_queue_entry->data.audio.audio_chunk);
break;
case ESPEAK_QET_INDEX_MARK:
- xfree(playback_queue_entry->data.markId);
+ g_free(playback_queue_entry->data.markId);
break;
case ESPEAK_QET_SOUND_ICON:
- xfree(playback_queue_entry->data.sound_icon_filename);
+ g_free(playback_queue_entry->data.sound_icon_filename);
break;
default:
break;
}
- xfree(playback_queue_entry);
+ g_free(playback_queue_entry);
}
/* Erases the entire playback queue, freeing memory. */
@@ -1168,7 +1168,7 @@ espeak_play_file(char *filename)
track.num_channels = sfinfo.channels;
track.sample_rate = sfinfo.samplerate;
track.bits = 16;
- track.samples = malloc(items * sizeof(short));
+ track.samples = g_malloc(items * sizeof(short));
if (NULL == track.samples) {
DBG("Espeak: ERROR: Cannot allocate audio buffer.");
result = FALSE;
@@ -1191,7 +1191,7 @@ espeak_play_file(char *filename)
DBG("Espeak: Sent to audio.");
}
cleanup2:
- xfree(track.samples);
+ g_free(track.samples);
cleanup1:
sf_close(sf);
#endif
diff --git a/src/modules/festival.c b/src/modules/festival.c
index 12df03d..ecf6791 100644
--- a/src/modules/festival.c
+++ b/src/modules/festival.c
@@ -86,7 +86,7 @@ struct{
}else{ \
f = g_ascii_strdown(param, -1); \
FEST_SEND_CMDA("("fest_param" \"%s\")", f); \
- xfree(f); \
+ g_free(f); \
} \
ret = festival_read_response(info, &r); \
if (ret != 0) return -1; \
@@ -94,7 +94,7 @@ struct{
if (resp != NULL) \
*resp = r; \
else \
- free(r); \
+ g_free(r); \
} \
return ret; \
}
@@ -107,7 +107,7 @@ struct{
if (festival_check_info(info, #name)) return -1; \
if (param == NULL) return -1; \
FEST_SEND_CMDA("("fest_param" '%s)", f = g_ascii_strdown(param, -1)); \
- xfree(f); \
+ g_free(f); \
return festival_read_response(info, NULL); \
}
@@ -278,7 +278,7 @@ module_init(char **status_info)
festival_voice_list = festivalGetVoices(festival_info);
/* Initialize global variables */
- festival_message = (char**) xmalloc (sizeof (char*));
+ festival_message = (char**) g_malloc (sizeof (char*));
*festival_message = NULL;
/* Initialize festival_speak thread to handle communication
@@ -387,8 +387,8 @@ module_speak(char *data, size_t bytes, EMessageType msgtype)
DBG("Requested data: |%s| \n", data);
- xfree(*festival_message);
- *festival_message = strdup(data);
+ g_free(*festival_message);
+ *festival_message = g_strdup(data);
if (*festival_message == NULL){
DBG("Error: Copying data unsuccesful.");
return -1;
@@ -536,7 +536,7 @@ static VoiceDescription** festivalGetVoices(FT_Info *info)
for (i=0; ; i++, num_voices++) if (voices[i] == NULL) break;
num_voices /= 3;
- result = (VoiceDescription**) malloc((num_voices +
1)*sizeof(VoiceDescription*));
+ result = (VoiceDescription**) g_malloc((num_voices +
1)*sizeof(VoiceDescription*));
for (i=0, j=0; ;j++){
if (voices[i] == NULL)
@@ -545,16 +545,16 @@ static VoiceDescription** festivalGetVoices(FT_Info *info)
continue;
else
{
- result[j] = (VoiceDescription*) malloc(sizeof(VoiceDescription));
+ result[j] = (VoiceDescription*) g_malloc(sizeof(VoiceDescription));
result[j]->name = voices[i];
lang = voices[i+1];
if ((lang != NULL) && (strcmp(lang, "nil")))
- result[j]->language = strdup(lang);
+ result[j]->language = g_strdup(lang);
else
result[j]->language = NULL;
dialect = voices[i+2];
if ((dialect != NULL) && (strcmp(dialect, "nil")))
- result[j]->dialect = strdup(dialect);
+ result[j]->dialect = g_strdup(dialect);
else
result[j]->dialect=NULL;
i+=3;
@@ -707,12 +707,12 @@ _festival_speak(void* nothing)
INDEX_MARK_BODY_LEN))){
DBG("Pause requested, pausing.");
module_report_index_mark(callback);
- xfree(callback);
+ g_free(callback);
festival_pause_requested = 0;
CLEAN_UP(0, module_report_event_pause);
}else{
module_report_index_mark(callback);
- xfree(callback);
+ g_free(callback);
continue;
}
}
@@ -734,7 +734,7 @@ _festival_speak(void* nothing)
DBG("Storing record for %s in cache\n", *festival_message);
/* cache_insert takes care of not inserting the same
message again */
- cache_insert(strdup(*festival_message), festival_message_type,
fwave);
+ cache_insert(g_strdup(*festival_message),
festival_message_type, fwave);
wave_cached = 1;
}
@@ -795,7 +795,7 @@ void
festival_set_language(char* language)
{
FestivalSetLanguage(festival_info, language, NULL);
- xfree(festival_voice_list);
+ g_free(festival_voice_list);
festival_voice_list = festivalGetVoices(festival_info);
}
@@ -806,7 +806,7 @@ festival_set_voice(EVoiceType voice)
voice_name = EVoice2str(voice);
FestivalSetVoice(festival_info, voice_name, NULL);
- xfree(voice_name);
+ g_free(voice_name);
}
void
@@ -840,7 +840,7 @@ festival_set_punctuation_mode(EPunctMode punct)
char *punct_mode;
punct_mode = EPunctMode2str(punct);
FestivalSetPunctuationMode(festival_info, punct_mode);
- xfree(punct_mode);
+ g_free(punct_mode);
}
void
@@ -851,7 +851,7 @@ festival_set_cap_let_recogn(ECapLetRecogn recogn)
if (recogn == RECOGN_NONE) recogn_mode = NULL;
else recogn_mode = ECapLetRecogn2str(recogn);
FestivalSetCapLetRecogn(festival_info, recogn_mode, NULL);
- xfree(recogn_mode);
+ g_free(recogn_mode);
}
@@ -861,8 +861,8 @@ void
cache_destroy_entry(gpointer data)
{
TCacheEntry *entry = data;
- xfree(entry->fwave);
- xfree(entry);
+ g_free(entry->fwave);
+ g_free(entry);
}
void
@@ -874,8 +874,8 @@ cache_destroy_table_entry(gpointer data)
void
cache_free_counter_entry(gpointer data, gpointer user_data)
{
- xfree(((TCounterEntry*)data)->key);
- xfree(data);
+ g_free(((TCounterEntry*)data)->key);
+ g_free(data);
}
int
@@ -885,7 +885,7 @@ cache_init()
if (FestivalCacheOn == 0) return 0;
FestivalCache.size = 0;
- FestivalCache.caches = g_hash_table_new_full(g_str_hash, g_str_equal, free,
+ FestivalCache.caches = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free,
cache_destroy_table_entry);
FestivalCache.cache_counter = NULL;
DBG("Cache: initialized");
@@ -1048,25 +1048,25 @@ cache_insert(char* key, EMessageType msgtype, FT_Wave
*fwave)
cache = g_hash_table_new(g_str_hash, g_str_equal);
g_hash_table_insert(FestivalCache.caches, key_table, cache);
}else{
- xfree(key_table);
+ g_free(key_table);
}
/* Fill the CounterEntry structure that will later allow us to remove
the less used entries from cache */
- centry = (TCounterEntry*) xmalloc(sizeof(TCounterEntry));
+ centry = (TCounterEntry*) g_malloc(sizeof(TCounterEntry));
centry->start = time(NULL);
centry->count = 1;
centry->size = fwave->num_samples * sizeof(short);
centry->p_caches = cache;
- centry->key = strdup(key);
+ centry->key = g_strdup(key);
FestivalCache.cache_counter = g_list_append(FestivalCache.cache_counter,
centry);
- entry = (TCacheEntry*) xmalloc(sizeof(TCacheEntry));
+ entry = (TCacheEntry*) g_malloc(sizeof(TCacheEntry));
entry->p_counter_entry = centry;
entry->fwave = fwave;
FestivalCache.size += centry->size;
- g_hash_table_insert(cache, strdup(key), entry);
+ g_hash_table_insert(cache, g_strdup(key), entry);
return 0;
}
@@ -1088,7 +1088,7 @@ cache_lookup(const char *key, EMessageType msgtype, int
add_counter)
if (key_table == NULL) return NULL;
cache = g_hash_table_lookup(FestivalCache.caches, key_table);
- xfree(key_table);
+ g_free(key_table);
if (cache == NULL) return NULL;
entry = g_hash_table_lookup(cache, key);
diff --git a/src/modules/festival_client.c b/src/modules/festival_client.c
index aef09eb..8c329e6 100644
--- a/src/modules/festival_client.c
+++ b/src/modules/festival_client.c
@@ -86,8 +86,8 @@ void delete_FT_Wave(FT_Wave *wave)
if (wave != 0)
{
if (wave->samples != 0)
- free(wave->samples);
- free(wave);
+ g_free(wave->samples);
+ g_free(wave);
}
}
@@ -154,7 +154,7 @@ int save_FT_Wave_snd(FT_Wave *wave, const char *filename)
void delete_FT_Info(FT_Info *info)
{
if (info != 0)
- free(info);
+ g_free(info);
}
/* --- FESTIVAL REPLY PARSING --- */
@@ -247,7 +247,7 @@ socket_receive_file_to_buff(int fd,int *size)
if (fd < 0) return NULL;
bufflen = 1024;
- buff = (char *)malloc(bufflen);
+ buff = (char *)g_malloc(bufflen);
*size=0;
for (k=0; file_stuff_key[k] != '\0';)
@@ -257,14 +257,14 @@ socket_receive_file_to_buff(int fd,int *size)
DBG("ERROR: FESTIVAL CLOSED CONNECTION (1)");
close(fd);
festival_connection_crashed = 1;
- xfree(buff);
+ g_free(buff);
return NULL; /* hit stream eof before end of file */
}
if ((*size)+k+1 >= bufflen)
{ /* +1 so you can add a NULL if you want */
bufflen += bufflen/4;
- buff = (char *)realloc(buff,bufflen);
+ buff = (char *)g_realloc(buff,bufflen);
}
if (file_stuff_key[k] == c)
k++;
@@ -328,12 +328,12 @@ static FT_Wave *client_accept_waveform(int fd, int
*stop_flag, int stop_by_close
if ((num_samples*sizeof(short))+1024 == filesize)
{
- wave = (FT_Wave *)malloc(sizeof(FT_Wave));
+ wave = (FT_Wave *)g_malloc(sizeof(FT_Wave));
DBG("Number of samples from festival: %d", num_samples);
wave->num_samples = num_samples;
wave->sample_rate = sample_rate;
if (num_samples != 0){
- wave->samples = (short *)
malloc(num_samples*sizeof(short));
+ wave->samples = (short *)
g_malloc(num_samples*sizeof(short));
memmove(wave->samples, wavefile+1024,
num_samples*sizeof(short));
if (nist_require_swap(wavefile))
for (i=0; i < num_samples; i++)
@@ -344,8 +344,7 @@ static FT_Wave *client_accept_waveform(int fd, int
*stop_flag, int stop_by_close
}
}
- if (wavefile != NULL) /* just in case we've got an ancient free() */
- free(wavefile);
+ g_free(wavefile);
return wave;
}
@@ -400,7 +399,7 @@ festival_read_response(FT_Info *info, char **expr)
*expr = client_accept_s_expr(info->server_fd);
}else{
r = client_accept_s_expr(info->server_fd);
- if (r != NULL) free(r);
+ if (r != NULL) g_free(r);
}
}
@@ -425,7 +424,7 @@ festival_accept_any_response(FT_Info *info)
client_accept_waveform(info->server_fd, NULL, 0);
}else if (strcmp(ack,"LP\n") == 0){ /* receive an s-expr */
expr = client_accept_s_expr(info->server_fd);
- if (expr != NULL) free(expr);
+ if (expr != NULL) g_free(expr);
}else if (strcmp(ack,"ER\n") == 0) /* server got an error */
{
/* This message ER is returned even if it was because there was
@@ -486,7 +485,7 @@ festivalOpen(FT_Info *info)
"Reason: %s", resp);
return NULL;
}
- free(resp);
+ g_free(resp);
FEST_SEND_CMD("(Parameter.set 'Wavefiletype 'nist)\n");
ret = festival_read_response(info, &resp);
@@ -494,7 +493,7 @@ festivalOpen(FT_Info *info)
DBG("ERROR: Can't set Wavefiletype to nist in Festival. Reason: %s",
resp);
return NULL;
}
- free(resp);
+ g_free(resp);
return info;
}
@@ -534,7 +533,7 @@ festival_speak_command(FT_Info *info, char *command, const
char *text, int symbo
DBG("-> Festival: escaped text is %s", text);
DBG("-> Festival: |%sthe text is displayed above\")|", str);
- free(str);
+ g_free(str);
/* Close the stream (but not the socket) */
fclose(fd);
DBG("Resources freed");
@@ -635,7 +634,7 @@ festivalGetDataMulti(FT_Info *info, char **callback, int
*stop_flag, int stop_by
if (strcmp(ack,"WV\n") == 0){
wave = client_accept_waveform(info->server_fd, stop_flag,
stop_by_close);
}else if (strcmp(ack,"LP\n") == 0){
- if (resp != NULL) free(resp);
+ if (resp != NULL) g_free(resp);
resp = client_accept_s_expr(info->server_fd);
if (resp == NULL){
DBG("ERROR: Something wrong in communication with Festival,
s_expr = NULL");
@@ -645,7 +644,7 @@ festivalGetDataMulti(FT_Info *info, char **callback, int
*stop_flag, int stop_by
DBG("<- Festival: |%s|", resp);
if (!strcmp(resp, "nil")){
DBG("festival_client: end of samples\n");
- free(resp);
+ g_free(resp);
wave = NULL;
resp = NULL;
}
@@ -657,7 +656,7 @@ festivalGetDataMulti(FT_Info *info, char **callback, int
*stop_flag, int stop_by
if (resp){
if ((strlen(resp) > 0) && (resp[0] != '#')) *callback = resp;
- else free (resp);
+ else g_free (resp);
}
return wave;
@@ -693,7 +692,7 @@ lisp_list_get_vect(char* expr)
size_t i,j;
len = strlen(expr);
- helper = xmalloc(sizeof(char) * (len+1));
+ helper = g_malloc(sizeof(char) * (len+1));
//Remove parenthesis
j=0;
@@ -731,7 +730,7 @@ char* vect_read_item(char **vect, char* field)
FT_Info *festivalDefaultInfo()
{
FT_Info *info;
- info = (FT_Info *) malloc(sizeof(FT_Info));
+ info = (FT_Info *) g_malloc(sizeof(FT_Info));
info->server_host = FESTIVAL_DEFAULT_SERVER_HOST;
info->server_port = FESTIVAL_DEFAULT_SERVER_PORT;
diff --git a/src/modules/festival_client.h b/src/modules/festival_client.h
index b0659e0..2ec0575 100644
--- a/src/modules/festival_client.h
+++ b/src/modules/festival_client.h
@@ -88,7 +88,7 @@ void delete_FT_Info(FT_Info *info);
str = g_strdup(format"\n"); \
fputs(str, fd); \
DBG("-> Festival: |%s|", str); \
- free(str); \
+ g_free(str); \
fclose(fd); \
}else{ \
DBG("Can't open connection"); \
@@ -104,7 +104,7 @@ void delete_FT_Info(FT_Info *info);
str = g_strdup_printf(format"\n", args); \
fputs(str, fd); \
DBG("-> Festival: |%s|", str); \
- free(str); \
+ g_free(str); \
fclose(fd); \
}else{ \
DBG("Can't open connection"); \
diff --git a/src/modules/flite.c b/src/modules/flite.c
index 42d102d..ff0fa82 100644
--- a/src/modules/flite.c
+++ b/src/modules/flite.c
@@ -118,7 +118,7 @@ module_init(char **status_info)
if (flite_voice == NULL){
DBG("Couldn't register the basic kal voice.\n");
- *status_info = strdup("Can't register the basic kal voice. "
+ *status_info = g_strdup("Can't register the basic kal voice. "
"Currently only kal is supported. Seems your
FLite "
"installation is incomplete.");
return -1;
@@ -127,7 +127,7 @@ module_init(char **status_info)
DBG("FliteMaxChunkLength = %d\n", FliteMaxChunkLength);
DBG("FliteDelimiters = %s\n", FliteDelimiters);
- flite_message = malloc (sizeof (char*));
+ flite_message = g_malloc (sizeof (char*));
*flite_message = NULL;
flite_semaphore = module_semaphore_init();
@@ -137,7 +137,7 @@ module_init(char **status_info)
ret = pthread_create(&flite_speak_thread, NULL, _flite_speak, NULL);
if(ret != 0){
DBG("Flite: thread failed\n");
- *status_info = strdup("The module couldn't initialize threads "
+ *status_info = g_strdup("The module couldn't initialize threads "
"This could be either an internal problem or an "
"architecture problem. If you are sure your
architecture "
"supports threads, please report a bug.");
@@ -146,7 +146,7 @@ module_init(char **status_info)
module_audio_id = NULL;
- *status_info = strdup("Flite initialized successfully.");
+ *status_info = g_strdup("Flite initialized successfully.");
return 0;
}
@@ -179,7 +179,7 @@ module_speak(gchar *data, size_t bytes, EMessageType
msgtype)
DBG("Requested data: |%s|\n", data);
if (*flite_message != NULL){
- xfree(*flite_message);
+ g_free(*flite_message);
*flite_message = NULL;
}
*flite_message = module_strip_ssml(data);
@@ -245,7 +245,7 @@ module_close(int status)
if (module_terminate_thread(flite_speak_thread) != 0)
exit(1);
- xfree(flite_voice);
+ g_free(flite_voice);
DBG("Closing audio output");
spd_audio_close(module_audio_id);
@@ -296,7 +296,7 @@ _flite_speak(void* nothing)
spd_audio_set_volume(module_audio_id, flite_volume);
/* TODO: free(buf) */
- buf = (char*) malloc((FliteMaxChunkLength+1) * sizeof(char));
+ buf = (char*) g_malloc((FliteMaxChunkLength+1) * sizeof(char));
pos = 0;
module_report_event_begin();
while(1){
@@ -397,7 +397,7 @@ _flite_speak(void* nothing)
}
}
flite_stop = 0;
- xfree(buf);
+ g_free(buf);
}
flite_speaking = 0;
diff --git a/src/modules/generic.c b/src/modules/generic.c
index 6ef1815..6d112a4 100644
--- a/src/modules/generic.c
+++ b/src/modules/generic.c
@@ -147,12 +147,12 @@ module_init(char **status_info)
DBG("GenericDelimiters = %s\n", GenericDelimiters);
DBG("GenericExecuteSynth = %s\n", GenericExecuteSynth);
- generic_msg_language = (TGenericLanguage*)
xmalloc(sizeof(TGenericLanguage));
- generic_msg_language->code = strdup("en");
- generic_msg_language->charset = strdup("iso-8859-1");
- generic_msg_language->name = strdup("english");
+ generic_msg_language = (TGenericLanguage*)
g_malloc(sizeof(TGenericLanguage));
+ generic_msg_language->code = g_strdup("en");
+ generic_msg_language->charset = g_strdup("iso-8859-1");
+ generic_msg_language->name = g_strdup("english");
- generic_message = malloc (sizeof (char*));
+ generic_message = g_malloc (sizeof (char*));
generic_semaphore = module_semaphore_init();
DBG("Generic: creating new thread for generic_speak\n");
@@ -160,14 +160,14 @@ module_init(char **status_info)
ret = pthread_create(&generic_speak_thread, NULL, _generic_speak, NULL);
if(ret != 0){
DBG("Generic: thread failed\n");
- *status_info = strdup("The module couldn't initialize threads"
+ *status_info = g_strdup("The module couldn't initialize threads"
"This can be either an internal problem or an"
"architecture problem. If you are sure your
architecture"
"supports threads, please report a bug.");
return -1;
}
- *status_info = strdup("Everything ok so far.");
+ *status_info = g_strdup("Everything ok so far.");
return 0;
}
@@ -226,8 +226,8 @@ module_speak(gchar *data, size_t bytes, EMessageType
msgtype)
if (msgtype == MSGTYPE_TEXT)
*generic_message = module_strip_ssml(tmp);
else
- *generic_message = strdup(tmp);
- xfree(tmp);
+ *generic_message = g_strdup(tmp);
+ g_free(tmp);
module_strip_punctuation_some(*generic_message, GenericStripPunctChars);
@@ -322,7 +322,7 @@ string_replace(char *string, const char* token, const char*
data)
/* Put it together, replacing token with data */
new = g_strdup_printf("%s%s%s", str1, data, str2);
- xfree(mstring);
+ g_free(mstring);
mstring = new;
}
@@ -381,15 +381,15 @@ _generic_speak(void* nothing)
helper = getenv("TMPDIR");
if (helper)
- tmpdir = strdup(helper);
+ tmpdir = g_strdup(helper);
else
- tmpdir = strdup("/tmp");
+ tmpdir = g_strdup("/tmp");
helper = g_get_home_dir();
if (helper)
- homedir = strdup(helper);
+ homedir = g_strdup(helper);
else
- homedir = strdup("UNKNOWN_HOME_DIRECTORY");
+ homedir = g_strdup("UNKNOWN_HOME_DIRECTORY");
play_command = spd_audio_get_playcmd(module_audio_id);
if (play_command == NULL) {
@@ -401,13 +401,13 @@ _generic_speak(void* nothing)
is also delivered to the child processes created by
system()) */
if (setpgid(0,0) == -1) DBG("Can't set myself as project group
leader!");
- e_string = strdup(GenericExecuteSynth);
+ e_string = g_strdup(GenericExecuteSynth);
e_string = string_replace(e_string, "$PLAY_COMMAND",
play_command);
e_string = string_replace(e_string, "$TMPDIR", tmpdir);
- xfree(tmpdir);
+ g_free(tmpdir);
e_string = string_replace(e_string, "$HOMEDIR", homedir);
- xfree(homedir);
+ g_free(homedir);
e_string = string_replace(e_string, "$PITCH",
generic_msg_pitch_str);
e_string = string_replace(e_string, "$RATE",
generic_msg_rate_str);
e_string = string_replace(e_string, "$VOLUME",
generic_msg_volume_str);
@@ -422,10 +422,10 @@ _generic_speak(void* nothing)
p = strstr(e_string, "$DATA");
if (p == NULL) exit(1);
*p = 0;
- execute_synth_str1 = strdup(e_string);
- execute_synth_str2 = strdup(p + (strlen("$DATA")));
+ execute_synth_str1 = g_strdup(e_string);
+ execute_synth_str2 = g_strdup(p + (strlen("$DATA")));
- free(e_string);
+ g_free(e_string);
/* execute_synth_str1 se sem musi nejak dostat */
DBG("Starting child...\n");
@@ -481,11 +481,11 @@ _generic_child(TModuleDoublePipe dpipe, const size_t
maxlen)
DBG("Entering child loop\n");
while(1){
/* Read the waiting data */
- text = malloc((maxlen + 1) * sizeof(char));
+ text = g_malloc((maxlen + 1) * sizeof(char));
bytes = module_child_dp_read(dpipe, text, maxlen);
DBG("read %d bytes in child", bytes);
if (bytes == 0){
- free(text);
+ g_free(text);
generic_child_close(dpipe);
}
@@ -504,7 +504,7 @@ _generic_child(TModuleDoublePipe dpipe, const size_t maxlen)
DBG("child: escaped text is |%s|", message->str);
- command = malloc((strlen(message->str)+strlen(execute_synth_str1)+
+ command = g_malloc((strlen(message->str)+strlen(execute_synth_str1)+
strlen(execute_synth_str2) + 8) * sizeof(char));
if (strlen(message->str) != 0){
@@ -521,8 +521,8 @@ _generic_child(TModuleDoublePipe dpipe, const size_t maxlen)
}
module_sigunblockusr(&some_signals);
- xfree(command);
- xfree(text);
+ g_free(command);
+ g_free(text);
g_string_free(message, 1);
DBG("child->parent: ok, send more data");
@@ -589,18 +589,18 @@ generic_set_language(char *lang)
lang);
if (generic_msg_language == NULL){
DBG("Language %s not found in the configuration file, using defaults.",
lang);
- generic_msg_language = (TGenericLanguage*)
xmalloc(sizeof(TGenericLanguage));
- generic_msg_language->code = strdup(lang);
+ generic_msg_language = (TGenericLanguage*)
g_malloc(sizeof(TGenericLanguage));
+ generic_msg_language->code = g_strdup(lang);
generic_msg_language->charset = NULL;
- generic_msg_language->name = strdup(lang);
+ generic_msg_language->name = g_strdup(lang);
}
if (generic_msg_language->name == NULL){
DBG("Language name for %s not found in the configuration file.", lang);
- generic_msg_language = (TGenericLanguage*)
xmalloc(sizeof(TGenericLanguage));
- generic_msg_language->code = strdup("en");
- generic_msg_language->charset = strdup("iso-8859-1");
- generic_msg_language->name = strdup("english");
+ generic_msg_language = (TGenericLanguage*)
g_malloc(sizeof(TGenericLanguage));
+ generic_msg_language->code = g_strdup("en");
+ generic_msg_language->charset = g_strdup("iso-8859-1");
+ generic_msg_language->name = g_strdup("english");
}
generic_set_voice(msg_settings.voice);
@@ -620,15 +620,15 @@ void
generic_set_punct(EPunctMode punct)
{
if (punct == PUNCT_NONE){
- generic_msg_punct_str = strdup((char*) GenericPunctNone);
+ generic_msg_punct_str = g_strdup((char*) GenericPunctNone);
return;
}
else if (punct == PUNCT_SOME){
- generic_msg_punct_str = strdup((char*) GenericPunctSome);
+ generic_msg_punct_str = g_strdup((char*) GenericPunctSome);
return;
}
else if (punct == PUNCT_ALL){
- generic_msg_punct_str = strdup((char*) GenericPunctAll);
+ generic_msg_punct_str = g_strdup((char*) GenericPunctAll);
return;
}
else{
diff --git a/src/modules/ibmtts.c b/src/modules/ibmtts.c
index 41628c6..799ef17 100644
--- a/src/modules/ibmtts.c
+++ b/src/modules/ibmtts.c
@@ -107,14 +107,14 @@ DECLARE_DEBUG();
T ## name *new_item; \
char *new_key; \
GList *dll = NULL; \
- new_item = (T ## name *) malloc(sizeof(T ## name)); \
- new_key = strdup(cmd->data.list[0]); \
+ new_item = (T ## name *) g_malloc(sizeof(T ## name)); \
+ new_key = g_strdup(cmd->data.list[0]); \
if (NULL != cmd->data.list[1]) \
- new_item->arg2 = strdup(cmd->data.list[1]); \
+ new_item->arg2 = g_strdup(cmd->data.list[1]); \
else \
new_item->arg2 = NULL; \
if (NULL != cmd->data.list[2]) \
- new_item->arg3 = strdup(cmd->data.list[2]); \
+ new_item->arg3 = g_strdup(cmd->data.list[2]); \
else \
new_item->arg3 = NULL; \
dll = g_hash_table_lookup(name, new_key); \
@@ -147,9 +147,9 @@ DECLARE_DEBUG();
{ \
T ## name *new_item; \
char* new_key; \
- new_item = (T ## name *) malloc(sizeof(T ## name)); \
+ new_item = (T ## name *) g_malloc(sizeof(T ## name)); \
if (cmd->data.list[0] == NULL) return NULL; \
- new_key = strdup(cmd->data.list[0]); \
+ new_key = g_strdup(cmd->data.list[0]); \
new_item->arg1 = (int) strtol(cmd->data.list[1], NULL, 10); \
new_item->arg2 = (int) strtol(cmd->data.list[2], NULL, 10); \
new_item->arg3 = (int) strtol(cmd->data.list[3], NULL, 10); \
@@ -427,7 +427,7 @@ module_init(char **status_info)
eciHandle = eciNew();
if (NULL_ECI_HAND == eciHandle ) {
DBG("Ibmtts: Could not create ECI instance.\n");
- *status_info = strdup("Could not create ECI instance. "
+ *status_info = g_strdup("Could not create ECI instance. "
"Is the IBM TTS engine installed?");
return FATAL_ERROR;
}
@@ -449,7 +449,7 @@ module_init(char **status_info)
}
/* Allocate a chunk for ECI to return audio. */
- audio_chunk = (TEciAudioSamples *) xmalloc((IbmttsAudioChunkSize) * sizeof
(TEciAudioSamples));
+ audio_chunk = (TEciAudioSamples *) g_malloc((IbmttsAudioChunkSize) *
sizeof (TEciAudioSamples));
DBG("Ibmtts: Registering ECI callback.");
eciRegisterCallback(eciHandle, eciCallback, NULL);
@@ -492,7 +492,7 @@ module_init(char **status_info)
*/
DBG("Ibmtts: ImbttsAudioChunkSize = %d", IbmttsAudioChunkSize);
- ibmtts_message = xmalloc (sizeof (char*));
+ ibmtts_message = g_malloc (sizeof (char*));
*ibmtts_message = NULL;
DBG("Ibmtts: Creating new thread for stop or pause.");
@@ -500,7 +500,7 @@ module_init(char **status_info)
ret = pthread_create(&ibmtts_stop_or_pause_thread, NULL,
_ibmtts_stop_or_pause, NULL);
if(0 != ret) {
DBG("Ibmtts: stop or pause thread creation failed.");
- *status_info = strdup("The module couldn't initialize stop or pause
thread. "
+ *status_info = g_strdup("The module couldn't initialize stop or pause
thread. "
"This could be either an internal problem or an "
"architecture problem. If you are sure your architecture "
"supports threads, please report a bug.");
@@ -512,7 +512,7 @@ module_init(char **status_info)
ret = pthread_create(&ibmtts_play_thread, NULL, _ibmtts_play, NULL);
if(0 != ret) {
DBG("Ibmtts: play thread creation failed.");
- *status_info = strdup("The module couldn't initialize play thread. "
+ *status_info = g_strdup("The module couldn't initialize play thread. "
"This could be either an internal problem or an "
"architecture problem. If you are sure your architecture "
"supports threads, please report a bug.");
@@ -524,7 +524,7 @@ module_init(char **status_info)
ret = pthread_create(&ibmtts_synth_thread, NULL, _ibmtts_synth, NULL);
if(0 != ret) {
DBG("Ibmtts: synthesis thread creation failed.");
- *status_info = strdup("The module couldn't initialize synthesis
thread. "
+ *status_info = g_strdup("The module couldn't initialize synthesis
thread. "
"This could be either an internal problem or an "
"architecture problem. If you are sure your architecture "
"supports threads, please report a bug.");
@@ -533,7 +533,7 @@ module_init(char **status_info)
module_audio_id = NULL;
- *status_info = strdup("Ibmtts: Initialized successfully.");
+ *status_info = g_strdup("Ibmtts: Initialized successfully.");
g_string_free(info, 1);
return OK;
@@ -570,7 +570,7 @@ module_speak(gchar *data, size_t bytes, EMessageType
msgtype)
DBG("Ibmtts: Type: %d, bytes: %d, requested data: |%s|\n", msgtype,
bytes, data);
- xfree(*ibmtts_message);
+ g_free(*ibmtts_message);
*ibmtts_message = NULL;
if (!g_utf8_validate(data, bytes, NULL)) {
@@ -685,7 +685,7 @@ module_close(int status)
eciHandle = NULL_ECI_HAND;
/* Free buffer for ECI audio. */
- xfree(audio_chunk);
+ g_free(audio_chunk);
DBG("Ibmtts: Closing audio output");
spd_audio_close(module_audio_id);
@@ -852,7 +852,7 @@ process_text_mark(char *part, int part_len, char *mark_name)
/* Handle index marks. */
if (NULL != mark_name) {
/* Assign the mark name an integer number and store in lookup table. */
- int *markId = (int *) xmalloc( sizeof (int) );
+ int *markId = (int *) g_malloc( sizeof (int) );
*markId = 1 + g_hash_table_size(ibmtts_index_mark_ht);
g_hash_table_insert(ibmtts_index_mark_ht, markId, mark_name);
if (!eciInsertIndex(eciHandle, *markId)) {
@@ -974,7 +974,7 @@ _ibmtts_synth(void* nothing)
DBG("Ibmtts: Key from Speech Dispatcher: |%s|", pos);
pos = ibmtts_subst_keys(pos);
DBG("Ibmtts: Key to speak: |%s|", pos);
- xfree(*ibmtts_message);
+ g_free(*ibmtts_message);
*ibmtts_message = pos;
eciSetParam(eciHandle, eciTextMode, eciTextModeDefault);
break;
@@ -1011,7 +1011,7 @@ _ibmtts_synth(void* nothing)
part_len = strlen(part);
pos += part_len;
ret = process_text_mark(part, part_len, mark_name);
- free(part);
+ g_free(part);
part = NULL;
mark_name = NULL;
if (ret == 1) pos += strlen(pos);
@@ -1107,12 +1107,12 @@ ibmtts_set_punctuation_mode(EPunctMode punct_mode)
{
const char* fmt = "`Pf%d%s";
size_t len = strlen(fmt) + strlen(IbmttsPunctuationList) + sizeof('\0');
- char* msg = malloc(len);
+ char* msg = g_malloc(len);
if (msg) {
snprintf(msg, len, fmt, punct_mode, IbmttsPunctuationList);
eciAddText(eciHandle, msg);
- free(msg);
+ g_free(msg);
}
}
@@ -1122,16 +1122,16 @@ ibmtts_voice_enum_to_str(EVoiceType voice)
/* TODO: Would be better to move this to module_utils.c. */
char *voicename;
switch (voice) {
- case NO_VOICE: voicename = strdup("no voice"); break;
- case MALE1: voicename = strdup("male1"); break;
- case MALE2: voicename = strdup("male2"); break;
- case MALE3: voicename = strdup("male3"); break;
- case FEMALE1: voicename = strdup("female1"); break;
- case FEMALE2: voicename = strdup("female2"); break;
- case FEMALE3: voicename = strdup("female3"); break;
- case CHILD_MALE: voicename = strdup("child_male"); break;
- case CHILD_FEMALE: voicename = strdup("child_female"); break;
- default: voicename = strdup("no voice"); break;
+ case NO_VOICE: voicename = g_strdup("no voice"); break;
+ case MALE1: voicename = g_strdup("male1"); break;
+ case MALE2: voicename = g_strdup("male2"); break;
+ case MALE3: voicename = g_strdup("male3"); break;
+ case FEMALE1: voicename = g_strdup("female1"); break;
+ case FEMALE2: voicename = g_strdup("female2"); break;
+ case FEMALE3: voicename = g_strdup("female3"); break;
+ case CHILD_MALE: voicename = g_strdup("child_male"); break;
+ case CHILD_FEMALE: voicename = g_strdup("child_female"); break;
+ default: voicename = g_strdup("no voice"); break;
}
return voicename;
}
@@ -1219,7 +1219,7 @@ ibmtts_set_language_and_voice(char *lang, EVoiceType
voice, char* dialect)
ret = eciSetVoiceParam(eciHandle, 0, eciSpeed, params->speed);
if (-1 == ret) DBG("Ibmtts: ERROR: Setting speed %i", params->speed);
}
- xfree(voicename);
+ g_free(voicename);
/* Retrieve the baseline pitch and speed of the voice. */
ibmtts_voice_pitch_baseline = eciGetVoiceParam(eciHandle, 0,
eciPitchBaseline);
if (-1 == ibmtts_voice_pitch_baseline) DBG("Ibmtts: Cannot get pitch
baseline of voice.");
@@ -1319,12 +1319,12 @@ static enum ECICallbackReturn eciCallback(
static TIbmttsBool
ibmtts_add_audio_to_playback_queue(TEciAudioSamples *audio_chunk, long
num_samples)
{
- TPlaybackQueueEntry *playback_queue_entry = (TPlaybackQueueEntry *)
xmalloc (sizeof (TPlaybackQueueEntry));
+ TPlaybackQueueEntry *playback_queue_entry = (TPlaybackQueueEntry *)
g_malloc (sizeof (TPlaybackQueueEntry));
if (NULL == playback_queue_entry) return IBMTTS_FALSE;
playback_queue_entry->type = IBMTTS_QET_AUDIO;
playback_queue_entry->data.audio.num_samples = (int) num_samples;
int wlen = sizeof (TEciAudioSamples) * num_samples;
- playback_queue_entry->data.audio.audio_chunk = (TEciAudioSamples *)
xmalloc (wlen);
+ playback_queue_entry->data.audio.audio_chunk = (TEciAudioSamples *)
g_malloc (wlen);
memcpy(playback_queue_entry->data.audio.audio_chunk, audio_chunk, wlen);
pthread_mutex_lock(&playback_queue_mutex);
playback_queue = g_slist_append(playback_queue, playback_queue_entry);
@@ -1336,7 +1336,7 @@ ibmtts_add_audio_to_playback_queue(TEciAudioSamples
*audio_chunk, long num_sampl
static TIbmttsBool
ibmtts_add_mark_to_playback_queue(long markId)
{
- TPlaybackQueueEntry *playback_queue_entry = (TPlaybackQueueEntry *)
xmalloc (sizeof (TPlaybackQueueEntry));
+ TPlaybackQueueEntry *playback_queue_entry = (TPlaybackQueueEntry *)
g_malloc (sizeof (TPlaybackQueueEntry));
if (NULL == playback_queue_entry) return IBMTTS_FALSE;
playback_queue_entry->type = IBMTTS_QET_INDEX_MARK;
playback_queue_entry->data.markId = markId;
@@ -1350,7 +1350,7 @@ ibmtts_add_mark_to_playback_queue(long markId)
static TIbmttsBool
ibmtts_add_flag_to_playback_queue(EPlaybackQueueEntryType type)
{
- TPlaybackQueueEntry *playback_queue_entry = (TPlaybackQueueEntry *)
xmalloc (sizeof (TPlaybackQueueEntry));
+ TPlaybackQueueEntry *playback_queue_entry = (TPlaybackQueueEntry *)
g_malloc (sizeof (TPlaybackQueueEntry));
if (NULL == playback_queue_entry) return IBMTTS_FALSE;
playback_queue_entry->type = type;
pthread_mutex_lock(&playback_queue_mutex);
@@ -1363,7 +1363,7 @@ ibmtts_add_flag_to_playback_queue(EPlaybackQueueEntryType
type)
static TIbmttsBool
ibmtts_add_sound_icon_to_playback_queue(char* filename)
{
- TPlaybackQueueEntry *playback_queue_entry = (TPlaybackQueueEntry *)
xmalloc (sizeof (TPlaybackQueueEntry));
+ TPlaybackQueueEntry *playback_queue_entry = (TPlaybackQueueEntry *)
g_malloc (sizeof (TPlaybackQueueEntry));
if (NULL == playback_queue_entry) return IBMTTS_FALSE;
playback_queue_entry->type = IBMTTS_QET_SOUND_ICON;
playback_queue_entry->data.sound_icon_filename = filename;
@@ -1379,15 +1379,15 @@ ibmtts_delete_playback_queue_entry(TPlaybackQueueEntry
*playback_queue_entry)
{
switch (playback_queue_entry->type) {
case IBMTTS_QET_AUDIO:
- xfree(playback_queue_entry->data.audio.audio_chunk);
+ g_free(playback_queue_entry->data.audio.audio_chunk);
break;
case IBMTTS_QET_SOUND_ICON:
- xfree(playback_queue_entry->data.sound_icon_filename);
+ g_free(playback_queue_entry->data.sound_icon_filename);
break;
default:
break;
}
- xfree(playback_queue_entry);
+ g_free(playback_queue_entry);
}
/* Erases the entire playback queue, freeing memory. */
@@ -1643,7 +1643,7 @@ ibmtts_play_file(char *filename)
track.num_channels = sfinfo.channels;
track.sample_rate = sfinfo.samplerate;
track.bits = 16;
- track.samples = xmalloc(items * sizeof(short));
+ track.samples = g_malloc(items * sizeof(short));
if (NULL == track.samples) {
DBG("Ibmtts: ERROR: Cannot allocate audio buffer.");
result = IBMTTS_FALSE;
@@ -1666,7 +1666,7 @@ ibmtts_play_file(char *filename)
DBG("Ibmtts: Sent to audio.");
}
cleanup2:
- xfree(track.samples);
+ g_free(track.samples);
cleanup1:
sf_close(sf);
#endif
@@ -1684,8 +1684,8 @@ alloc_voice_list()
if (eciGetAvailableLanguages(aLanguage, &nLanguages))
return;
- ibmtts_voice_list = malloc((nLanguages+1)*sizeof(VoiceDescription*));
- ibmtts_voice_index = malloc((nLanguages+1)*sizeof(VoiceDescription*));
+ ibmtts_voice_list = g_malloc((nLanguages+1)*sizeof(VoiceDescription*));
+ ibmtts_voice_index = g_malloc((nLanguages+1)*sizeof(VoiceDescription*));
if (!ibmtts_voice_list)
return;
@@ -1693,7 +1693,7 @@ alloc_voice_list()
for(i=0; i<nLanguages; i++) {
/* look for the language name */
int j;
- ibmtts_voice_list[i] = malloc(sizeof(VoiceDescription));
+ ibmtts_voice_list[i] = g_malloc(sizeof(VoiceDescription));
DBG("Ibmtts: aLanguage[%d]=0x%08x", i, aLanguage[i]);
for (j=0; j<MAX_NB_OF_LANGUAGES; j++) {
@@ -1719,7 +1719,7 @@ free_voice_list()
int i=0;
if (ibmtts_voice_index) {
- free(ibmtts_voice_index);
+ g_free(ibmtts_voice_index);
ibmtts_voice_index = NULL;
}
@@ -1727,9 +1727,9 @@ free_voice_list()
return;
for(i=0; ibmtts_voice_list[i]; i++) {
- free(ibmtts_voice_list[i]);
+ g_free(ibmtts_voice_list[i]);
}
- free(ibmtts_voice_list);
+ g_free(ibmtts_voice_list);
ibmtts_voice_list = NULL;
}
diff --git a/src/modules/ivona.c b/src/modules/ivona.c
index 5b5e28d..ff9fbe1 100644
--- a/src/modules/ivona.c
+++ b/src/modules/ivona.c
@@ -134,7 +134,7 @@ module_init(char **status_info)
/* Init Ivona */
if (ivona_init_sock(IvonaServerHost, IvonaServerPort)) {
DBG("Couldn't init socket parameters");
- *status_info = strdup("Can't initialize socket. "
+ *status_info = g_strdup("Can't initialize socket. "
"Check server host/port.");
return -1;
}
@@ -142,7 +142,7 @@ module_init(char **status_info)
DBG("IvonaDelimiters = %s\n", IvonaDelimiters);
- ivona_message = malloc (sizeof (char*));
+ ivona_message = g_malloc (sizeof (char*));
*ivona_message = NULL;
ivona_semaphore = module_semaphore_init();
@@ -152,7 +152,7 @@ module_init(char **status_info)
ret = pthread_create(&ivona_speak_thread, NULL, _ivona_speak, NULL);
if(ret != 0){
DBG("Ivona: thread failed\n");
- *status_info = strdup("The module couldn't initialize threads "
+ *status_info = g_strdup("The module couldn't initialize threads "
"This could be either an internal problem or an "
"architecture problem. If you are sure your
architecture "
"supports threads, please report a bug.");
@@ -161,7 +161,7 @@ module_init(char **status_info)
module_audio_id = NULL;
- *status_info = strdup("Ivona initialized successfully.");
+ *status_info = g_strdup("Ivona initialized successfully.");
return 0;
}
@@ -197,7 +197,7 @@ module_speak(gchar *data, size_t bytes, EMessageType
msgtype)
DBG("Requested data: |%s|\n", data);
if (*ivona_message != NULL){
- xfree(*ivona_message);
+ g_free(*ivona_message);
*ivona_message = NULL;
}
*ivona_message = module_strip_ssml(data);
@@ -348,7 +348,7 @@ static int ivona_get_msgpart(struct dumbtts_conf *conf,
EMessageType type,
n=dumbtts_WCharString(conf,wc,*buf,*len,cap_mode,&isicon);
if (n>0) {
*len=n+128;
- *buf=xrealloc(*buf,*len);
+ *buf=g_realloc(*buf,*len);
n=dumbtts_WCharString(conf,wc,*buf,*len,cap_mode,&isicon);
}
if (n) {
@@ -370,7 +370,7 @@ static int ivona_get_msgpart(struct dumbtts_conf *conf,
EMessageType type,
DBG("Got n=%d",n);
if (n>0) {
*len=n+128;
- *buf=xrealloc(*buf,*len);
+ *buf=g_realloc(*buf,*len);
if (type == MSGTYPE_KEY) {
n=dumbtts_KeyString(conf,*msg,*buf,*len,cap_mode,&isicon);
}
@@ -399,7 +399,7 @@ static int ivona_get_msgpart(struct dumbtts_conf *conf,
EMessageType type,
if (n>0) {
*len=n+128;
- *buf=xrealloc(*buf,*len);
+ *buf=g_realloc(*buf,*len);
n=dumbtts_GetString(conf,xbuf,*buf,*len,punct_mode,punct_some,",.;:!?");
}
if (n) {
@@ -550,7 +550,7 @@ _ivona_speak(void* nothing)
track.samples = ((short *)audio)+offset;
DBG("Got %d samples", track.num_samples);
spd_audio_play(module_audio_id, track, SPD_AUDIO_LE);
- xfree(audio);
+ g_free(audio);
audio=NULL;
}
if (ivona_stop) {
@@ -560,9 +560,9 @@ _ivona_speak(void* nothing)
}
}
ivona_stop=0;
- xfree(buf);
- xfree(audio);
- xfree(next_audio);
+ g_free(buf);
+ g_free(audio);
+ g_free(next_audio);
if (fd>=0) close(fd);
fd=-1;
audio=NULL;
diff --git a/src/modules/ivona_client.c b/src/modules/ivona_client.c
index 99f3247..031b46a 100644
--- a/src/modules/ivona_client.c
+++ b/src/modules/ivona_client.c
@@ -91,10 +91,10 @@ char *ivona_get_wave_fd(int fd,int *nsamples,int *offset)
wave_size=BASE_WAVE_SIZE;
wave_length=0;
- ivona_wave=xmalloc(wave_size);
+ ivona_wave=g_malloc(wave_size);
for (;;) {
if (wave_size <wave_length + 8192) {
- ivona_wave=xrealloc(ivona_wave,wave_size +
STEP_WAVE_SIZE);
+ ivona_wave=g_realloc(ivona_wave,wave_size +
STEP_WAVE_SIZE);
wave_size += STEP_WAVE_SIZE;
}
DBG("Have place for %d bytes",wave_size - wave_length);
@@ -107,7 +107,7 @@ char *ivona_get_wave_fd(int fd,int *nsamples,int *offset)
w=(short *) ivona_wave;
for (i=wave_length/2-1;i>=0;i--) if (w[i]) break;
if (i<100) {
- xfree(ivona_wave);
+ g_free(ivona_wave);
return NULL;
}
DBG("Trimmed %d samples at end",wave_length/2-i-1);
@@ -182,7 +182,7 @@ ivona_play_file(char *filename)
track.num_channels = sfinfo.channels;
track.sample_rate = sfinfo.samplerate;
track.bits = 16;
- track.samples = malloc(items * sizeof(short));
+ track.samples = g_malloc(items * sizeof(short));
if (NULL == track.samples) {
DBG("Ivona: ERROR: Cannot allocate audio buffer.");
result = FALSE;
@@ -205,7 +205,7 @@ ivona_play_file(char *filename)
DBG("Ivona: Sent to audio.");
}
cleanup2:
- xfree(track.samples);
+ g_free(track.samples);
cleanup1:
sf_close(sf);
#endif
@@ -281,10 +281,10 @@ void ivona_store_wave_in_cache(char *str,char *wave,int
samples)
else {
ica=find_min_count();
if (!ica) return;
- xfree(ica->wave);
+ g_free(ica->wave);
}
ica->count=1;
- ica->wave=xmalloc(samples*2);
+ ica->wave=g_malloc(samples*2);
memcpy(ica->wave,wave,samples*2);
ica->samples=samples;
strcpy(ica->str,str);
@@ -299,7 +299,7 @@ char *ivona_get_wave_from_cache(char *to_say,int *samples)
for (ica=ica_tail.succ;ica && ica->samples;ica=ica->succ) {
DBG("Cache cmp '%s'='%s'",ica->str,to_say);
if (!strcmp(ica->str,to_say)) {
- char *wave=xmalloc(ica->samples*2);
+ char *wave=g_malloc(ica->samples*2);
memcpy(wave,ica->wave,ica->samples*2);
*samples=ica->samples;
ica->count++;
diff --git a/src/modules/module_main.c b/src/modules/module_main.c
index 661e701..77cf136 100644
--- a/src/modules/module_main.c
+++ b/src/modules/module_main.c
@@ -49,7 +49,7 @@ if (!strcmp(cmd_buf, #command"\n")){ \
} \
fflush(stdout); \
pthread_mutex_unlock(&module_stdout_mutex);\
- xfree(msg); \
+ g_free(msg); \
}
#define PROCESS_CMD_W_ARGS(command, function) \
@@ -62,7 +62,7 @@ if (!strncmp(cmd_buf, #command, strlen(#command))){ \
} \
fflush(stdout); \
pthread_mutex_unlock(&module_stdout_mutex);\
- xfree(msg); \
+ g_free(msg); \
}
#define PROCESS_CMD_NRP(command, function) \
@@ -89,7 +89,7 @@ main(int argc, char *argv[])
module_audio_id = 0;
if (argc >= 2){
- configfilename = strdup(argv[1]);
+ configfilename = g_strdup(argv[1]);
}else{
configfilename = NULL;
}
@@ -111,7 +111,7 @@ main(int argc, char *argv[])
dotconf_cleanup(configfile);
DBG("Configuration (pre) has been read from \"%s\"\n",
configfilename);
- xfree(configfilename);
+ g_free(configfilename);
}else{
DBG("Can't read specified config file!\n");
}
@@ -137,7 +137,7 @@ main(int argc, char *argv[])
ret = printf("%s\n", "399 ERR CANT INIT MODULE");
return -1;
}
- xfree(status_info);
+ g_free(status_info);
if (ret < 0){
DBG("Broken pipe, exiting...\n");
@@ -148,7 +148,7 @@ main(int argc, char *argv[])
DBG("ERROR: Wrong communication from module client: didn't call
INIT\n");
module_close(3);
}
- xfree(cmd_buf);
+ g_free(cmd_buf);
while(1){
cmd_buf = NULL; n=0;
@@ -177,7 +177,7 @@ main(int argc, char *argv[])
fflush(stdout);
}
- xfree(cmd_buf);
+ g_free(cmd_buf);
}
}
diff --git a/src/modules/module_utils.c b/src/modules/module_utils.c
index ff19bbf..11cbaa2 100644
--- a/src/modules/module_utils.c
+++ b/src/modules/module_utils.c
@@ -54,7 +54,7 @@ ssize_t getline (char **lineptr, size_t *n, FILE *f)
if ( m++ >= buf_len )
{
buf_len += BUFFER_LEN;
- buf = (char *) realloc(buf, buf_len + 1);
+ buf = (char *) g_realloc(buf, buf_len + 1);
if ( buf == NULL )
{
DBG("buf==NULL");
@@ -80,37 +80,6 @@ ssize_t getline (char **lineptr, size_t *n, FILE *f)
}
#endif /* !(defined(__GLIBC__) && defined(_GNU_SOURCE)) */
-void*
-xmalloc(size_t size)
-{
- void *p;
-
- p = malloc(size);
- if (p == NULL) FATAL("Not enough memmory");
- return p;
-}
-
-void*
-xrealloc(void *data, size_t size)
-{
- void *p;
-
- if (data != NULL)
- p = realloc(data, size);
- else
- p = malloc(size);
-
- if (p == NULL) FATAL("Not enough memmory");
-
- return p;
-}
-
-void
-xfree(void *data)
-{
- if (data != NULL) free(data);
-}
-
char*
do_message(EMessageType msgtype)
{
@@ -130,24 +99,24 @@ do_message(EMessageType msgtype)
n = 0;
ret = getline(&cur_line, &n, stdin);
nlines++;
- if (ret == -1) return strdup("401 ERROR INTERNAL");
+ if (ret == -1) return g_strdup("401 ERROR INTERNAL");
if (!strcmp(cur_line, "..\n")){
- xfree(cur_line);
- cur_line = strdup(".\n");
+ g_free(cur_line);
+ cur_line = g_strdup(".\n");
}else if (!strcmp(cur_line, ".\n")){
/* Strip the trailing \n */
msg->str[strlen(msg->str)-1] = 0;
- xfree(cur_line);
+ g_free(cur_line);
break;
}
g_string_append(msg, cur_line);
- xfree(cur_line);
+ g_free(cur_line);
}
if ((msgtype != MSGTYPE_TEXT) && (nlines > 2)){
- return strdup("305 DATA MORE THAN ONE LINE");
+ return g_strdup("305 DATA MORE THAN ONE LINE");
}
if ((msgtype == MSGTYPE_CHAR) && (!strcmp(msg->str,"space"))){
@@ -159,15 +128,15 @@ do_message(EMessageType msgtype)
if (msg->str == NULL || msg->str[0] == 0){
DBG("requested data NULL or empty\n");
g_string_free(msg, TRUE);
- return strdup("301 ERROR CANT SPEAK");
+ return g_strdup("301 ERROR CANT SPEAK");
}
ret = module_speak(msg->str, strlen(msg->str), msgtype);
g_string_free(msg,1);
- if (ret <= 0) return strdup("301 ERROR CANT SPEAK");
+ if (ret <= 0) return g_strdup("301 ERROR CANT SPEAK");
- return strdup("200 OK SPEAKING");
+ return g_strdup("200 OK SPEAKING");
}
char*
@@ -225,9 +194,9 @@ do_pause(void)
#define SET_PARAM_STR(name) \
if(!strcmp(cur_item, #name)){ \
- xfree(msg_settings.name); \
+ g_free(msg_settings.name); \
if(!strcmp(cur_value, "NULL")) msg_settings.name = NULL; \
- else msg_settings.name = strdup(cur_value); \
+ else msg_settings.name = g_strdup(cur_value); \
}
#define SET_PARAM_STR_C(name, fconv) \
@@ -256,7 +225,7 @@ do_set(void)
ret = getline(&line, &n, stdin);
if (ret == -1){ err=1; break; }
if (!strcmp(line, ".\n")){
- xfree(line);
+ g_free(line);
break;
}
if (!err){
@@ -276,21 +245,21 @@ do_set(void)
else SET_PARAM_STR(language)
else err=2; /* Unknown parameter */
}
- xfree(line);
+ g_free(line);
}
- if (err == 0) return strdup("203 OK SETTINGS RECEIVED");
- if (err == 1) return strdup("302 ERROR BAD SYNTAX");
- if (err == 2) return strdup("303 ERROR INVALID PARAMETER OR VALUE");
+ if (err == 0) return g_strdup("203 OK SETTINGS RECEIVED");
+ if (err == 1) return g_strdup("302 ERROR BAD SYNTAX");
+ if (err == 2) return g_strdup("303 ERROR INVALID PARAMETER OR VALUE");
- return strdup("401 ERROR INTERNAL"); /* Can't be reached */
+ return g_strdup("401 ERROR INTERNAL"); /* Can't be reached */
}
#define SET_AUDIO_STR(name,idx) \
if(!strcmp(cur_item, #name)){ \
- xfree(module_audio_pars[idx]); \
+ g_free(module_audio_pars[idx]); \
if(!strcmp(cur_value, "NULL")) module_audio_pars[idx] = NULL; \
- else module_audio_pars[idx] = strdup(cur_value); \
+ else module_audio_pars[idx] = g_strdup(cur_value); \
}
char*
@@ -313,7 +282,7 @@ do_audio(void)
ret = getline(&line, &n, stdin);
if (ret == -1){ err=1; break; }
if (!strcmp(line, ".\n")){
- xfree(line);
+ g_free(line);
break;
}
if (!err){
@@ -330,11 +299,11 @@ do_audio(void)
else SET_AUDIO_STR(audio_pulse_min_length, 5)
else err=2; /* Unknown parameter */
}
- xfree(line);
+ g_free(line);
}
- if (err == 1) return strdup("302 ERROR BAD SYNTAX");
- if (err == 2) return strdup("303 ERROR INVALID PARAMETER OR VALUE");
+ if (err == 1) return g_strdup("302 ERROR BAD SYNTAX");
+ if (err == 2) return g_strdup("303 ERROR INVALID PARAMETER OR VALUE");
err = module_audio_init(&status);
@@ -375,7 +344,7 @@ do_loglevel(void)
ret = getline(&line, &n, stdin);
if (ret == -1){ err=1; break; }
if (!strcmp(line, ".\n")){
- xfree(line);
+ g_free(line);
break;
}
if (!err){
@@ -387,11 +356,11 @@ do_loglevel(void)
SET_LOGLEVEL_NUM(log_level, 1)
else err=2; /* Unknown parameter */
}
- xfree(line);
+ g_free(line);
}
- if (err == 1) return strdup("302 ERROR BAD SYNTAX");
- if (err == 2) return strdup("303 ERROR INVALID PARAMETER OR VALUE");
+ if (err == 1) return g_strdup("302 ERROR BAD SYNTAX");
+ if (err == 2) return g_strdup("303 ERROR INVALID PARAMETER OR VALUE");
msg = g_strdup_printf("203 OK LOG LEVEL SET");
@@ -410,13 +379,13 @@ do_debug(char* cmd_buf)
if (!cmd[1]){
g_strfreev(cmd);
- return strdup("302 ERROR BAD SYNTAX");
+ return g_strdup("302 ERROR BAD SYNTAX");
}
if (!strcmp(cmd[1], "ON")){
if (!cmd[2]){
g_strfreev(cmd);
- return strdup("302 ERROR BAD SYNTAX");
+ return g_strdup("302 ERROR BAD SYNTAX");
}
@@ -426,7 +395,7 @@ do_debug(char* cmd_buf)
if (CustomDebugFile == NULL){
DBG("ERROR: Can't open custom debug file for logging: %d (%s)",
errno, strerror(errno));
- return strdup("303 CANT OPEN CUSTOM DEBUG FILE");
+ return g_strdup("303 CANT OPEN CUSTOM DEBUG FILE");
}
if (Debug == 1)
Debug = 3;
@@ -445,7 +414,7 @@ do_debug(char* cmd_buf)
CustomDebugFile = NULL;
DBG("Additional logging into specific path terminated");
}else{
- return strdup("302 ERROR BAD SYNTAX");
+ return g_strdup("302 ERROR BAD SYNTAX");
}
g_strfreev(cmd);
@@ -462,7 +431,7 @@ do_list_voices(void)
voices = module_list_voices();
if (voices == NULL){
- return strdup("304 CANT LIST VOICES");
+ return g_strdup("304 CANT LIST VOICES");
}
voice_list = g_string_new("");
@@ -485,7 +454,7 @@ do_list_voices(void)
/* check whether we found at least one voice */
if (voice_list->len == 0){
g_string_free(voice_list, TRUE);
- return strdup("304 CANT LIST VOICES");
+ return g_strdup("304 CANT LIST VOICES");
}
g_string_append(voice_list, "200 OK VOICE LIST SENT");
@@ -605,7 +574,7 @@ module_strip_ssml(char *message)
assert(message != NULL);
len = strlen(message);
- out = (char*) xmalloc(sizeof(char) * (len+1));
+ out = (char*) g_malloc(sizeof(char) * (len+1));
for (i = 0, n = 0; i <= len; i++){
@@ -728,7 +697,7 @@ module_parent_wfork(TModuleDoublePipe dpipe, const char*
message, EMessageType m
DBG("Entering parent process, closing pipes");
- buf = (char*) malloc((maxlen+1) * sizeof(char));
+ buf = (char*) g_malloc((maxlen+1) * sizeof(char));
module_parent_dp_init(dpipe);
@@ -954,12 +923,12 @@ module_semaphore_init()
sem_t *semaphore;
int ret;
- semaphore = (sem_t *) malloc(sizeof(sem_t));
+ semaphore = (sem_t *) g_malloc(sizeof(sem_t));
if (semaphore == NULL) return NULL;
ret = sem_init(semaphore, 0, 0);
if (ret != 0){
DBG("Semaphore initialization failed");
- xfree(semaphore);
+ g_free(semaphore);
semaphore = NULL;
}
return semaphore;
@@ -970,7 +939,7 @@ module_recode_to_iso(char *data, int bytes, char *language,
char *fallback)
{
char *recoded;
- if (language == NULL) recoded = strdup(data);
+ if (language == NULL) recoded = g_strdup(data);
if (!strcmp(language, "cs"))
recoded = (char*) g_convert_with_fallback(data, bytes, "ISO8859-2",
"UTF-8",
@@ -1019,7 +988,7 @@ module_report_index_mark(char *mark)
module_send_asynchronous(reply);
- xfree(reply);
+ g_free(reply);
}
void
@@ -1060,8 +1029,8 @@ module_add_config_option(configoption_t *options, int
*num_options, char *name,
assert(name != NULL);
num_config_options++;
- opts = (configoption_t*) realloc(options, (num_config_options+1) *
sizeof(configoption_t));
- opts[num_config_options-1].name = (char*) strdup(name);
+ opts = (configoption_t*) g_realloc(options, (num_config_options+1) *
sizeof(configoption_t));
+ opts[num_config_options-1].name = (char*) g_strdup(name);
opts[num_config_options-1].type = type;
opts[num_config_options-1].callback = callback;
opts[num_config_options-1].info = info;
@@ -1092,8 +1061,8 @@ add_config_option(configoption_t *options, int
*num_config_options, char *name,
configoption_t *opts;
(*num_config_options)++;
- opts = (configoption_t*) realloc(options, (*num_config_options) *
sizeof(configoption_t));
- opts[*num_config_options-1].name = strdup(name);
+ opts = (configoption_t*) g_realloc(options, (*num_config_options) *
sizeof(configoption_t));
+ opts[*num_config_options-1].name = g_strdup(name);
opts[*num_config_options-1].type = type;
opts[*num_config_options-1].callback = callback;
opts[*num_config_options-1].info = info;
diff --git a/src/modules/module_utils.h b/src/modules/module_utils.h
index 785ac75..def27e5 100644
--- a/src/modules/module_utils.h
+++ b/src/modules/module_utils.h
@@ -109,7 +109,7 @@ int module_num_dc_options;
struct timeval tv; \
char *tstr; \
t = time(NULL); \
- tstr = strdup(ctime(&t)); \
+ tstr = g_strdup(ctime(&t)); \
tstr[strlen(tstr)-1] = 0; \
gettimeofday(&tv,NULL); \
fprintf(stderr," %s [%d]",tstr, (int) tv.tv_usec); \
@@ -124,7 +124,7 @@ int module_num_dc_options;
fprintf(CustomDebugFile, "\n"); \
fflush(CustomDebugFile); \
} \
- xfree(tstr); \
+ g_free(tstr); \
}
#define FATAL(msg) { \
@@ -160,7 +160,7 @@ void module_close (int status);
{ \
if (msg_settings_old.value != NULL) \
{ \
- xfree (msg_settings_old.value); \
+ g_free (msg_settings_old.value); \
msg_settings_old.value = NULL; \
} \
if (msg_settings.value != NULL) \
@@ -177,9 +177,6 @@ typedef struct{
int cp[2];
}TModuleDoublePipe;
-void* xmalloc(size_t size);
-void* xrealloc(void* data, size_t size);
-void xfree(void* data);
int module_get_message_part(const char* message, char* part,
unsigned int *pos, size_t maxlen,
@@ -265,9 +262,9 @@ configoption_t * add_config_option(configoption_t *options,
int *num_config_opti
static char *name = NULL; \
DOTCONF_CB(name ## _cb) \
{ \
- xfree(name); \
+ g_free(name); \
if (cmd->data.str != NULL) \
- name = strdup(cmd->data.str); \
+ name = g_strdup(cmd->data.str); \
return NULL; \
}
@@ -299,9 +296,9 @@ configoption_t * add_config_option(configoption_t *options,
int *num_config_opti
DOTCONF_CB(name ## _cb) \
{ \
if (cmd->data.list[0] != NULL) \
- name.arg1 = strdup(cmd->data.list[0]); \
+ name.arg1 = g_strdup(cmd->data.list[0]); \
if (cmd->data.list[1] != NULL) \
- name.arg2 = strdup(cmd->data.list[1]); \
+ name.arg2 = g_strdup(cmd->data.list[1]); \
return NULL; \
}
@@ -316,12 +313,12 @@ configoption_t * add_config_option(configoption_t
*options, int *num_config_opti
{ \
T ## name *new_item; \
char* new_key; \
- new_item = (T ## name *) malloc(sizeof(T ## name)); \
+ new_item = (T ## name *) g_malloc(sizeof(T ## name)); \
if (cmd->data.list[0] == NULL) return NULL; \
- new_item->arg1 = strdup(cmd->data.list[0]); \
- new_key = strdup(cmd->data.list[0]); \
+ new_item->arg1 = g_strdup(cmd->data.list[0]); \
+ new_key = g_strdup(cmd->data.list[0]); \
if (cmd->data.list[1] != NULL) \
- new_item->arg2 = strdup(cmd->data.list[1]); \
+ new_item->arg2 = g_strdup(cmd->data.list[1]); \
else \
new_item->arg2 = NULL; \
g_hash_table_insert(name, new_key, new_item); \
@@ -340,16 +337,16 @@ configoption_t * add_config_option(configoption_t
*options, int *num_config_opti
{ \
T ## name *new_item; \
char* new_key; \
- new_item = (T ## name *) malloc(sizeof(T ## name)); \
+ new_item = (T ## name *) g_malloc(sizeof(T ## name)); \
if (cmd->data.list[0] == NULL) return NULL; \
- new_item->arg1 = strdup(cmd->data.list[0]); \
- new_key = strdup(cmd->data.list[0]); \
+ new_item->arg1 = g_strdup(cmd->data.list[0]); \
+ new_key = g_strdup(cmd->data.list[0]); \
if (cmd->data.list[1] != NULL) \
- new_item->arg2 = strdup(cmd->data.list[1]); \
+ new_item->arg2 = g_strdup(cmd->data.list[1]); \
else \
new_item->arg2 = NULL; \
if (cmd->data.list[2] != NULL) \
- new_item->arg3 = strdup(cmd->data.list[2]); \
+ new_item->arg3 = g_strdup(cmd->data.list[2]); \
else \
new_item->arg3 = NULL; \
g_hash_table_insert(name, new_key, new_item); \
@@ -357,7 +354,7 @@ configoption_t * add_config_option(configoption_t *options,
int *num_config_opti
}
#define MOD_OPTION_1_STR_REG(name, default) \
- if (default != NULL) name = strdup(default); \
+ if (default != NULL) name = g_strdup(default); \
else name = NULL; \
module_dc_options = module_add_config_option(module_dc_options, \
&module_num_dc_options, #name, \
diff --git a/src/modules/module_utils_addvoice.c
b/src/modules/module_utils_addvoice.c
index c02ea51..f828712 100644
--- a/src/modules/module_utils_addvoice.c
+++ b/src/modules/module_utils_addvoice.c
@@ -80,7 +80,7 @@ DOTCONF_CB(AddVoice_cb)
voices = g_hash_table_lookup(module_voice_table, language);
if (voices == NULL){
key = (char*) g_strdup(language);
- value = (SPDVoiceDef*) xmalloc(sizeof(SPDVoiceDef));
+ value = (SPDVoiceDef*) g_malloc(sizeof(SPDVoiceDef));
value->male1=NULL; value->male2=NULL; value->male3=NULL;
value->female1=NULL; value->female2=NULL; value->female3=NULL;
--
1.7.3
- [PATCH] Convert src/modules to use GLib memory management exclusively.,
Christopher Brannon <=
- [PATCH] Convert src/modules to use GLib memory management exclusively., Andrei Kholodnyi, 2010/09/24
- [PATCH] Convert src/modules to use GLib memory management exclusively., Christopher Brannon, 2010/09/24
- [PATCH] Convert src/modules to use GLib memory management exclusively., Andrei Kholodnyi, 2010/09/24
- [PATCH] Convert src/modules to use GLib memory management exclusively., Christopher Brannon, 2010/09/24
- [PATCH] Convert src/modules to use GLib memory management exclusively., Andrei Kholodnyi, 2010/09/24
- [PATCH] Convert src/modules to use GLib memory management exclusively., Andrei Kholodnyi, 2010/09/28
- [PATCH] Convert src/modules to use GLib memory management exclusively., Boris Dusek, 2010/09/28
- [PATCH] Convert src/modules to use GLib memory management exclusively., Christopher Brannon, 2010/09/28
- [PATCH] Convert src/modules to use GLib memory management exclusively., Trevor Saunders, 2010/09/24
- [PATCH] Convert src/modules to use GLib memory management exclusively., Christopher Brannon, 2010/09/24