memory allocation clarification
cmbrannon79 at gmail.com
Mon Feb 22 12:33:48 CET 2010
Jose Vilmar Estacio de Souza wrote:
> Yes, in attach to this message.
> Basicly the patch tries to replace all class to malloc and free, for
> g_malloc and g_free. Some calls to strdup were replace for g_strdup.
Thanks. Sorry it took me a while to reply.
You have the right idea.
I'm not sure about changing xmalloc, xrealloc,
and xfree so that they call glib's allocation functions. Those are wrappers
around the libc routines. I'm inclined to leave them alone, just for
the sake of code readability.
Realize that glib's allocation functions don't need to be wrapped, since
they already abort the program on allocation failure.
Perhaps it's better to just change the call sites to g_malloc, where needed?
I would leave getline alone as well. That needs to use libc's malloc.
GNU's libc provides getline for most of us,
and that version uses malloc internally.
The getline defined in module_utils.c is provided for Solaris. Evidently,
they don't link against GNU's libc.
I'll try to send a patch later, and I'll give you credit for your work in
the commit message.
More information about the Speechd