[Asterisk-Dev] newbie C programmer,
problems with Malloc in Asterisk application
Chih-Wei Huang
cwhuang at citron.com.tw
Tue Dec 13 18:57:56 MST 2005
Moises Silva wrote:
> Thanks Marc. I have read about alloca(), malloc(), free() etc. And yes,in
> fact im freeing the memory used by malloc with free(). So I dont know why it
> dies (and even if i did not free the memory, should not die for a single
> call does it?).
>
> the whole file is in:
> http://galileo.ivsol.net/scripts/app_dumpchan.c
>
First, this is a list for Asterisk development, not for
a C language training for a newbie.
Your problem didn't related to any development of Asterisk.
You just misused the realloc function:
vars_buffer = (char *)realloc(vars_buffer, new_string_size);
The pointer passed to realloc must be a pointer returned by
malloc/calloc/realloc. You can't use it to adjust a static buffer.
More information about the asterisk-dev
mailing list