i'm trying to use xavps in new version of t serial functions and have a couple of questions:
- when xavp value of type SR_XTYPE_STR is added using xavp_add_value function, do i need to make a copy of the string using pkg_malloc? in normal avps this is not needed, but for some reason a copy is made in sql_api.c.
- what is xavp equivalent of usr_avp avp_destroy, which takes one argument: pointer to usr_avp to be destroyed? there is xavp_rm, but it takes two arguments and i didn't find from the sources any example of its use.
-- juha
9 dec 2012 kl. 06:22 skrev jh@tutpro.com:
i'm trying to use xavps in new version of t serial functions and have a couple of questions:
- when xavp value of type SR_XTYPE_STR is added using xavp_add_value
function, do i need to make a copy of the string using pkg_malloc? in normal avps this is not needed, but for some reason a copy is made in sql_api.c.
- what is xavp equivalent of usr_avp avp_destroy, which takes one
argument: pointer to usr_avp to be destroyed? there is xavp_rm, but it takes two arguments and i didn't find from the sources any example of its use.
In addition: Xavps are not as well documented as avps. We need to add something. There's a wiki page with a proposal from Daniel, but I don't know if it documents the way it turned out in the code.
/O
Hello,
On 12/9/12 6:22 AM, jh@tutpro.com wrote:
i'm trying to use xavps in new version of t serial functions and have a couple of questions:
- when xavp value of type SR_XTYPE_STR is added using xavp_add_value function, do i need to make a copy of the string using pkg_malloc? in normal avps this is not needed, but for some reason a copy is made in sql_api.c.
you don't need to clone it to pkg, the xavp functions will make a clone to shared memory anyhow. Alex Hermann added the sql_xquery(), I don't know why he decided to clone, it is not necessary and the pkg-alloc'ed value is feed after the execution of xavp add function.
- what is xavp equivalent of usr_avp avp_destroy, which takes one argument: pointer to usr_avp to be destroyed? there is xavp_rm, but it takes two arguments and i didn't find from the sources any example of its use.
An xavp can contain a list of xavps. If you delete from the root list, then provide NULL as second param.
Cheers, Daniel
On Monday 10 December 2012 10:33:50 Daniel-Constantin Mierla wrote:
On 12/9/12 6:22 AM, jh@tutpro.com wrote:
i'm trying to use xavps in new version of t serial functions and have a couple of questions:
- when xavp value of type SR_XTYPE_STR is added using xavp_add_value function, do i need to make a copy of the string using pkg_malloc? in normal avps this is not needed, but for some reason a copy is made in sql_api.c.
you don't need to clone it to pkg, the xavp functions will make a clone to shared memory anyhow. Alex Hermann added the sql_xquery(), I don't know why he decided to clone, it is not necessary and the pkg-alloc'ed value is feed after the execution of xavp add function.
I didn't initially know that the string would be cloned automatically. After i learned it would, i changed some code i wrote to not clone them manually. I must have missed this one, i'll fix it in the near future.