concatenate problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Samuel

Thanks for help,I didn't realized it.
Now I'm trying with such code which I found in pj samples:

pj_str_t s3;
#define SNULL 0
	pj_pool_t *pool;
	int i;
	pj_pool_factory *mem; 

    pool = pj_pool_create(mem, SNULL, 4096, 0, SNULL);
	if (!pool){ _TSP_DTRACE(" --< pj_pool_create false >-- ");
		return false;}

	s3.ptr = (char*) pj_pool_alloc(pool, 256);
    if (!s3.ptr) { _TSP_DTRACE(" --< pj_ pj_pool_alloc false >-- ");
	return false;}


No compilation errors, but if my program reaches it - it hangs up. I think maybe something's wrong with pj_pool_factory *mem; because I put it by my self and couldn't found any sample and now I don't have time to dig in documentation. 
Do You have any sample code that will works for my case?

Thanks
Michal
 

>Michal
>
>You can look in source code, but I think pj_strcat works like strcat (man strcat in google).
>http://www.manpagez.com/man/3/strcat/
>
>     The strcat() and strncat() functions append a copy of the null-terminated
>     string s2 to the end of the null-terminated string s1, then add a termi-
>     nating `\0'.  The string s1 must have sufficient space to hold the
>     result.
>
>     The strncat() function appends not more than n characters from s2, and
>     then adds a terminating `\0'.
>
>So you need to allocate the pointer to the correct size, with malloc or you should prefer pj_pool.
>
>Samuel
>
>Micha? a ?crit :
>>> Maybe you need to allocate output ;-)
>>>     
>> Samuel, what do you mean? Sorry if this isn't the smartest
>> question(I'm not good programmer) but do:  pj_str_t output =
>> pj_str("");
>> isn't enough for that?
>>
>> Michal
>>
>>
>> Dnia 18 maja 2009 21:05 Samuel Vinson <samuelv at laposte.net> napisa?(a):
>>
>>   
>>> Michal
>>>
>>> Maybe you need to allocate output ;-)
>>>
>>> Samuel
>>>
>>> Micha? a ?crit :
>>>     
>>>> Hi,
>>>>
>>>> I wanted concatenate: "sip:"user"@"domain,where
>>>> domain is char * passed to the function but my program exits on the
>>>> first pj_strcat2. I can't find why.
>>>> this is part of my function: 
>>>>
>>>> SinReg(char *sipserv)
>>>> {
>>>> ....
>>>> pj_str_t output = pj_str("");
>>>> pj_strcat2(&output,"sip:"); //here program exits
>>>> pj_strcat2(&output,"user");
>>>> pj_strcat2(&output,"@");
>>>> pj_strcat(&output,&pj_str(sipserv));
>>>>
>>>> ...
>>>> }
>>>>
>>>> Thanks for any help
>>>> Michael





[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux