how to resize with pjlib?

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

 



Thanks, Man

BTW, 
    client ---------------------------------------- server
       MESSAGE (cseq=1, branch=a)--------->
            <------------------------------------407
       MESSAGE (cseq=1, branch=b)--------->

Branch has changed but cseq doesn't when responding to the challenge. Is this a bug? 

Also, rfc 3428 (page 10), defines " the header fields that can be used in   MESSAGE requests and responses"
		Header Field       where  proxy  MESSAGE
                   __________________________________________
                   Accept               R              -
                   Accept              2xx             -
                   Accept              415             m*
                   Contact              R              -
                   Contact             1xx             -
                   Contact             2xx             -
                   Contact             3xx             o
                   Contact             485             oI'm using the 0.8 release and MESSAGE carries the above headers.

best,
Nigel

> Date: Thu, 27 Mar 2008 19:52:52 +0000
> From: bennylp@xxxxxxxxx
> To: pjsip at lists.pjsip.org
> Subject: Re: how to resize with pjlib?
> 
> On Thu, Mar 27, 2008 at 12:23 PM, Nigel Hsiung <nigelcz at hotmail.com> wrote:
> >
> >  Hi list,
> >
> > I've got a few questions -
> >
> > 1. What is the pjlib equivalent to a realloc()?
> 
> Nothing. If you configure the pool to automatically resize (by setting
> the "increment size" argument to non zero when you create the pool),
> the pool will resize itself automatically anytime you allocate a
> memory chunk from the pool and there's no space left in the pool. If
> you don't configure pool to automatically resize, or if the resize
> operation fails, then the pool will throw PJ_NO_MEMORY_EXCEPTION
> exception.
> 
> > 2. Can i do this -
> >
> >     char str1[32] = {"123456"};
> >     char str2[32] ={"123456789012345"};
> >     char str3[32] ={"1234"};
> >     char str4[32] ={"1234678"};
> >
> >     pj_str_t  pj_string;
> >
> >     //1st call
> >     pj_strdup2_with_null(pool, &pj_string, str1); // no problem here
> >
> >     //2nd call
> >     if(pj_string.slen > strlen(str2))
> >         pj_strcpy2(&pj_string, str2);   //no problem here too
> >     else
> >         pj_strdup2_with_null(pool, &pj_string, str2); // ok to call
> > pj_strdup2 again?
> 
> Yes it's okay.
> 
> >    //3rd call with str3 ...
> >
> >    //4th call with str4
> >    // cannot use pj_string.slen to decide whether to pj_strcpy or pj_strdup,
> > right?
> 
> In general, yes. The "slen" member of the pj_str_t only says about the
> string length, and not the size of the buffer allocated by the pool
> and which was assigned to "ptr" member of pj_str_t. I think there are
> three ways to solve this:
> 
> 1. always call pj_strdup() to assign your string.
> 2. allocate a fixed, large size capacity to the string, e.g.:
> 
>      pj_string.ptr = pj_pool_alloc(pool, MAX_LEN);
> 
>      if (strlen(str1) <= MAX_LEN) pj_strcpy2(&pj_string, str1);
>      else error();
> 
>      if (strlen(str2) <= MAX_LEN) pj_strcpy2(&pj_string, str2);
>      else error();
> 
> 3. maintain the capacity information yourself, e.g.:
> 
>     int capacity = MAX_LEN;
>     pj_string.ptr = pj_pool_alloc(pool, capacity);
> 
>     if (strlen(str1) <= capacity) pj_strcpy2(&pj_string, str1);
>     else capacity=strlen(str1), pj_strdup2(pool, &pj_string, str1);
> 
>     if (strlen(str2) <= capacity) pj_strcpy2(&pj_string, str2);
>     else capacity=strlen(str2), pj_strdup2(pool, &pj_string, str2);
> 
> Cheers
>  Benny
> 
> 
> >     Please help!
> >
> > thanks,
> > Nigel
> 
> _______________________________________________
> Visit our blog: http://blog.pjsip.org
> 
> pjsip mailing list
> pjsip at lists.pjsip.org
> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

_________________________________________________________________
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20080331/0edfeb6b/attachment-0001.html 


[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