RESOLVED WONTFIX 75760
Give OwnPtr/PassOwnPtr the ability to deal with array types (making way to get rid of OwnArrayPtr/PassOwnArrayPtr)
https://bugs.webkit.org/show_bug.cgi?id=75760
Summary Give OwnPtr/PassOwnPtr the ability to deal with array types (making way to ge...
Sam Weinig
Reported 2012-01-06 16:44:06 PST
Give OwnPtr/PassOwnPtr the ability to deal with array types (making way to get rid of OwnArrayPtr/PassOwnArrayPtr)
Attachments
Patch (17.62 KB, patch)
2012-01-06 16:50 PST, Sam Weinig
no flags
Patch (20.12 KB, patch)
2012-01-06 18:52 PST, Sam Weinig
no flags
Sam Weinig
Comment 1 2012-01-06 16:50:13 PST
WebKit Review Bot
Comment 2 2012-01-06 16:53:26 PST
Attachment 121522 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/ChangeLog', u'Source..." exit_code: 1 Tools/TestWebKitAPI/Tests/PassOwnPtr.cpp:51: Local variables should never be PassOwnPtr (see http://webkit.org/coding/RefPtr.html). [readability/pass_ptr] [5] Tools/TestWebKitAPI/Tests/PassOwnPtr.cpp:62: Local variables should never be PassOwnPtr (see http://webkit.org/coding/RefPtr.html). [readability/pass_ptr] [5] Tools/TestWebKitAPI/Tests/PassOwnPtr.cpp:73: Local variables should never be PassOwnPtr (see http://webkit.org/coding/RefPtr.html). [readability/pass_ptr] [5] Total errors found: 3 in 11 files If any of these errors are false positives, please file a bug against check-webkit-style.
Sam Weinig
Comment 3 2012-01-06 18:52:52 PST
WebKit Review Bot
Comment 4 2012-01-06 18:55:00 PST
Attachment 121531 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/ChangeLog', u'Source..." exit_code: 1 Tools/TestWebKitAPI/Tests/PassOwnPtr.cpp:52: Local variables should never be PassOwnPtr (see http://webkit.org/coding/RefPtr.html). [readability/pass_ptr] [5] Tools/TestWebKitAPI/Tests/PassOwnPtr.cpp:63: Local variables should never be PassOwnPtr (see http://webkit.org/coding/RefPtr.html). [readability/pass_ptr] [5] Tools/TestWebKitAPI/Tests/PassOwnPtr.cpp:74: Local variables should never be PassOwnPtr (see http://webkit.org/coding/RefPtr.html). [readability/pass_ptr] [5] Tools/TestWebKitAPI/Tests/PassOwnPtr.cpp:85: Local variables should never be PassOwnPtr (see http://webkit.org/coding/RefPtr.html). [readability/pass_ptr] [5] Total errors found: 4 in 11 files If any of these errors are false positives, please file a bug against check-webkit-style.
Sam Weinig
Comment 5 2012-01-06 18:59:31 PST
The second version of this patch moves the type conversions to a shared OwnPtrTypes struct and introduces adoptArray as a sibling to adoptPtr. adoptArray is necessary because pointer decay makes it impossible to determine in adoptPtr whether the argument is an array type or not. This would lead to something like { adoptPtr(new Foo[5]); } crashing due to calling the wrong delete function.
Sam Weinig
Comment 6 2012-01-08 11:51:37 PST
Comment on attachment 121531 [details] Patch Actually, this isn't quite what we want, since OwnArrayPtr had an operator[]. I think we can get that by instead of using a single templatized class that serves both simple pointers and arrays, use a specialization for array types that adds the operator[]. At that point though, I am not sure how much it makes sense to do it.
Sam Weinig
Comment 7 2013-10-28 17:38:12 PDT
We are just going to use std::unique_ptr instead.
Note You need to log in before you can comment on or make changes to this bug.