[Scummvm-devel] zero bytes in Common::String

Vladimir Menshakov whoozle at yandex.ru
Tue Jun 29 12:23:22 CEST 2010



29.06.10, 14:06, "Willem Jan Palenstijn" <wjp at usecode.org>:

> Hi,
>  
>  There's some confusion in Common::String about whether zero bytes are allowed
>  in Common::String or not.
>  
>  The String::String(char c) constructor has an explicit comment saying it's
>  allowed, but many methods use either c_str() internally or strcmp, strstr, ...,
>  which might lead to surprising behaviour.
>  
>  And as fuzzie pointed out on IRC, String &String::operator=(char c) is also
>  inconsistent with String::String(char c) in this respect.
>  
>  Any opinions on what we should do?
>  
>  Unless there's a reason we need zero byte support in strings, the easiest would
>  be simply saying it's not allowed and leads to undefined behaviour.
Why not to mimic all common strings classes and allow any data inside as long as you specify its length?
If not, use legacy(and slow O(N)) const char * ctor / operator=()
>  
>  
>  -Willem Jan
>  
>  ------------------------------------------------------------------------------
>  This SF.net email is sponsored by Sprint
>  What will you do first with EVO, the first 4G phone?
>  Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
>  _______________________________________________
>  Scummvm-devel mailing list
>  Scummvm-devel at lists.sourceforge.net
>  https://lists.sourceforge.net/lists/listinfo/scummvm-devel
>  
>  




More information about the Scummvm-devel mailing list