[Asterisk-Dev] ast_callerid_parse destroying the cid info

Tilghman Lesher tilghman at mail.jeffandtilghman.com
Fri Apr 1 11:48:25 MST 2005


On Friday 01 April 2005 11:59, Matt Gibson wrote:
> 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()?

Why not use ast_strdupa() instead?

-- 
Tilghman



More information about the asterisk-dev mailing list