[sr-dev] How to cast int val from db and cast to str?
Andrew Mortensen
admorten at isc.upenn.edu
Tue Jan 29 20:53:19 CET 2013
On Jan 29, 2013, at 1:54 PM, Mino Haluz <mino.haluz at gmail.com> wrote:
> Hi,
>
> I'm changing carrierroute module so that it could set into another avp the ID of the rule that was chosen. I have already adjusted all functions but I have still one problem when kamailio starts.
>
> tmp_id.s=(char *)row->values[COL_ID].val.string_val;
>
> It gives Segfault at this line. The question is, how can I convert the row value that is int(10) to char (tmp_id is const str *, it is the same as comment). Thanks,
Use int2str from ut.h:
tmp_id.s = int2str(row->values[COL_ID].val.int_val, &tmp_id.len)
Note that int2str uses an internal static buffer that's overwritten on each call.
andrew
More information about the sr-dev
mailing list