memory allocation clarification
jose vilmar estacio de souza
vilmar at informal.com.br
Sat Feb 20 13:35:14 CET 2010
Hi Chris,
The example you gave in src/modules/module_utils.c was what caught my
attention.
I was investigating a problem with the sd_ibmtts and I came across this
situation.
What I did as an experiment, was to replace in the routines xmalloc and
xfree the calls malloc and free for g_malloc and g_free.
Coincidentally after that, I worked all day and the problem did not happen.
Are you trying to fix these problems?
I am asking because I am trying too but I don't know speech-dispatcher
code very well.
BTW, the problem that I am facing with sd_ibmtts, is that sometimes it
receives a SIGSEGV. The problem happens in different routines.
Thanks.
On 02/20/2010 12:09 AM, Chris Brannon wrote:
> Luke Yelavich<luke.yelavich at canonical.com> wrote:
>
>> On Thu, Feb 18, 2010 at 11:58:35AM EST, jose vilmar estacio de souza wrote:
>>
>>> It's important to match |g_malloc()|<http://library.gnome.org/devel/glib/u
>>>
>> nstable/glib-Memory-Allocation.html#g-malloc>
>>
>>> with |g_free()|<http://library.gnome.org/devel/glib/unstable/glib-Memory-A
>>>
>> llocation.html#g-free>,
>>
> *SNIP*
>
>>> Am I missing something?
>>>
>> This sounds correct. I believe one of Chris' recent patches for
>> speech-dispatcher corrected such an issue.
>>
> Right. g_malloc, g_free, malloc, and free are regularly mixed
> in the code. I'll give a couple notable examples.
>
> src/modules/module_utils.c defines a function named module_strip_ssml.
> It returns a pointer to memory allocated with libc's malloc.
> In src/modules/ibmtts.c, that memory is freed with g_free,
> while in src/modules/flite.c, it is freed with libc's free.
>
> src/c/api/libspeechd.c defines a function named
> spd_send_data_wo_mutex. This function can return either malloc'ed or
> g_malloc'ed data, depending on the condition of an if statement.
> Its caller has no way of knowing whether the memory was allocated by libc
> or glib.
>
> -- Chris
>
> _______________________________________________
> Speechd mailing list
> Speechd at lists.freebsoft.org
> http://lists.freebsoft.org/mailman/listinfo/speechd
>
More information about the Speechd
mailing list