[webkit-reviews] review granted: [Bug 58058] Replace WKStringGetCharactersPtr() with WKStringGetCharacters() : [Attachment 88670] Patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Apr 7 12:07:25 PDT 2011


Adam Roben (:aroben) <aroben at apple.com> has granted Jeff Miller
<jeffm at apple.com>'s request for review:
Bug 58058: Replace WKStringGetCharactersPtr() with WKStringGetCharacters()
https://bugs.webkit.org/show_bug.cgi?id=58058

Attachment 88670: Patch
https://bugs.webkit.org/attachment.cgi?id=88670&action=review

------- Additional Comments from Adam Roben (:aroben) <aroben at apple.com>
View in context: https://bugs.webkit.org/attachment.cgi?id=88670&action=review

> Source/WebKit2/Shared/WebString.h:68
> +	   if (bufferLength > length)
> +	       bufferLength = length;

You could use std::min here.

> Source/WebKit2/Shared/API/c/WKString.cpp:58
> +    return (toImpl(stringRef)->getCharacters(static_cast<UChar*>(buffer),
bufferLength));

I'm a little surprised you don't need reinterpret_cast here.

> Tools/TestWebKitAPI/Tests/WebKit2/WKString.cpp:60
> +    maxSize = WKStringGetLength(string);
> +    TEST_ASSERT(maxSize == 5);
> +
> +    WKChar* uniBuffer = new WKChar[maxSize];
> +    actualSize = WKStringGetCharacters(string, uniBuffer, maxSize);
> +    TEST_ASSERT(actualSize == 5);
> +    
> +    WKChar helloBuffer[] = { 'h', 'e', 'l', 'l', 'o' };
> +    TEST_ASSERT(!memcmp(uniBuffer, helloBuffer, 10));
> +    
> +    delete[] uniBuffer;
> +    

Might be good to have tests that pass in buffers that are larger and smaller
than needed.


More information about the webkit-reviews mailing list