[Kamailio-Devel] why setting int val to pvar also sets str val?

Juha Heinanen jh at tutpro.com
Wed Sep 3 08:22:24 CEST 2008


i started to wonder how it is possible that acc module succeeds to log
an int pvar value as a string without doing any conversion.  a look at
pvar.c revealed this:

/**
 * convert signed int to pv_value_t
 */
int pv_get_sintval(struct sip_msg *msg, pv_param_t *param,
		pv_value_t *res, int sival)
{
	int l = 0;
	char *ch = NULL;

	if(res==NULL)
		return -1;

	ch = int2str(sival, &l);
	res->rs.s = ch;
	res->rs.len = l;

	res->ri = sival;
	res->flags = PV_VAL_STR|PV_VAL_INT|PV_TYPE_INT;
	return 0;
}

question: why is cpu cycles wasted in int2str conversion for every int
valued pvar?  would it be better to do the conversion in the application
IF it needs str version of int val?

-- juha



More information about the Devel mailing list