[Asterisk-Dev] ast_callerid_parse destroying the cid info

Matt Gibson gibson at experthost.com
Fri Apr 1 10:59:04 MST 2005


Kevin P. Fleming wrote:
> Matt Gibson wrote:
> 
>> The problem that I am having is like this. When ast_callerid_parse is 
>> run on the callerid, it functions as expected, but if you try to use 
>> the same callerid elsewhere, it has been destroyed and cannot be used. 
>> Is there a way to put the variables into memory so it does not need to 
>> be reparsed, but is just available at all times?
> 
> 
> The buffer you pass in is destructively parsed, and pointers to the 
> name/number portions are stored in the variables you supply to the 
> function.
> 
> If you need to have the input string undisturbed, then you need to copy 
> it first before letting the function parse it.


Hi Kevin,

If I were to make a copy of the cid string, is it ok to use malloc() and
free() to allocate/deallocate memory for storing a copy? Are there no
memory management wrapper functions that must/should be used instead of
direct calls to malloc() or free()?

Thanks,
Matt



More information about the asterisk-dev mailing list