zval strings must be NULL terminated, even if they contain binary data. The str.val.len property represents the length of the string w/o the terminating NULL.
Zeev At 16:39 14/05/2002, Robert Cummings wrote: >brad lafountain wrote: > > > > Well i do believe that the zval string SHOULD be null termiated and > have the > > length stored. > >You would think so, but on further thought, if that were the case you >wouldn't be able to store compressed data from gzip in a string because >the null bytes everywhere would interfere. Also, as I said, ZVAL_STRING >suggests that this is so... since when you use it to set a zval container >to a string it saves the length as strlen( passedString ), rather >than strlen( passedString ) + 1, also the memcpy then uses this length >to copy the string if you set the copy flag to true. > >Cheers, >Rob. >------------------------------------------------------------------------ > > > > > But zend does provied this api function > > > > zend_binary_zval_strcmp(zval *, zval*); > > > > - Brad > > > > --- Robert Cummings <[EMAIL PROTECTED]> wrote: > > > zval containers that are of string type don't seem to hold > > > a null terminating character, but rather directly store the > > > length of the string - I note this because of how the > > > ZVAL_STRING macro works... My question then is what is the > > > best way to compare two strings in a zval? I would imagine > > > a macro or function would already exist, and I'm quite sure > > > that the following simple invocation is asking for trouble: > > > > > > strcmp( Z_STRVAL_P( target1 ), Z_STRVAL_P( target2 ) ) == 0 > > > > > > Thanks for any information. > > > > > > Cheers, > > > Rob. > > > -- > > > .-----------------. > > > | Robert Cummings | > > > :-----------------`----------------------------. > > > | Webdeployer - Chief PHP and Java Programmer | > > > :----------------------------------------------: > > > | Mail : mailto:[EMAIL PROTECTED] | > > > | Phone : (613) 731-4046 x.109 | > > > :----------------------------------------------: > > > | Website : http://www.webmotion.com | > > > | Fax : (613) 260-9545 | > > > `----------------------------------------------' > > > > > > -- > > > PHP Development Mailing List <http://www.php.net/> > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > __________________________________________________ > > Do You Yahoo!? > > LAUNCH - Your Yahoo! Music Experience > > http://launch.yahoo.com > >-- >.-----------------. >| Robert Cummings | >:-----------------`----------------------------. >| Webdeployer - Chief PHP and Java Programmer | >:----------------------------------------------: >| Mail : mailto:[EMAIL PROTECTED] | >| Phone : (613) 731-4046 x.109 | >:----------------------------------------------: >| Website : http://www.webmotion.com | >| Fax : (613) 260-9545 | >`----------------------------------------------' > >-- >PHP Development Mailing List <http://www.php.net/> >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php