Bug 129828 - Use OwnPtr in StructureIDTable
Summary: Use OwnPtr in StructureIDTable
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Hahnenberg
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-06 14:29 PST by Mark Hahnenberg
Modified: 2014-03-08 21:46 PST (History)
1 user (show)

See Also:


Attachments
Patch (5.33 KB, patch)
2014-03-06 14:30 PST, Mark Hahnenberg
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Hahnenberg 2014-03-06 14:29:07 PST
This reduces the amount of boilerplate, plus fixes a memory leak :-(
Comment 1 Mark Hahnenberg 2014-03-06 14:29:59 PST
<rdar://problem/16246441>
Comment 2 Mark Hahnenberg 2014-03-06 14:30:42 PST
Created attachment 226040 [details]
Patch
Comment 3 Geoffrey Garen 2014-03-06 14:36:47 PST
Comment on attachment 226040 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=226040&action=review

r=me

> Source/JavaScriptCore/runtime/StructureIDTable.cpp:50
>      StructureOrOffset* newTable = new StructureOrOffset[newCapacity];

You should use OwnPtr here.

> Source/JavaScriptCore/runtime/StructureIDTable.cpp:59
> +    StructureOrOffset* oldTable = m_table.leakPtr();

You should use PassOwnPtr here.

Another option is plain old swap.
Comment 4 Mark Hahnenberg 2014-03-07 09:07:58 PST
Committed r165265: <http://trac.webkit.org/changeset/165265>
Comment 5 Mark Hahnenberg 2014-03-07 09:08:16 PST
Comment on attachment 226040 [details]
Patch

Clearing review flag.
Comment 6 Darin Adler 2014-03-08 21:46:43 PST
In new code, please use std::unique_ptr instead of OwnPtr, which we are planning to deprecate and delete.