Bug 75848 - [EFL] Replace malloc/calloc/free to new/delete
Summary: [EFL] Replace malloc/calloc/free to new/delete
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit EFL (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-09 05:48 PST by Tomasz Morawski
Modified: 2012-02-29 00:58 PST (History)
7 users (show)

See Also:


Attachments
First patch (30.50 KB, patch)
2012-01-27 08:15 PST, Tomasz Morawski
rakuco: review-
Details | Formatted Diff | Diff
Next patch (29.95 KB, patch)
2012-02-27 06:47 PST, Tomasz Morawski
no flags Details | Formatted Diff | Diff
Fixed Raphael's comment (30.00 KB, patch)
2012-02-28 00:00 PST, Tomasz Morawski
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tomasz Morawski 2012-01-09 05:48:57 PST
Replace malloc/calloc/free functions calls to new/delete operator calls
Comment 1 Alexey Proskuryakov 2012-01-09 10:08:04 PST
We shouldn't just blindly do that, see e.g. bug 45735. What specific instances of malloc/free would you like to change?
Comment 2 Alexey Proskuryakov 2012-01-09 10:08:25 PST
Or is this only about WebKit EFL layer, not WebCore?
Comment 3 Gyuyoung Kim 2012-01-09 17:45:21 PST
(In reply to comment #2)
> Or is this only about WebKit EFL layer, not WebCore?

AFAIK, this patch will focus on EFL layer. He will add [EFL] to Bug title.
Comment 4 Tomasz Morawski 2012-01-09 23:24:16 PST
(In reply to comment #2)
> Or is this only about WebKit EFL layer, not WebCore?
Yes, it is EFL only. I am sorry for confusion. :)
Comment 5 Gyuyoung Kim 2012-01-25 22:21:12 PST
Any update ?
Comment 6 Tomasz Morawski 2012-01-25 23:27:03 PST
(In reply to comment #5)
> Any update ?
I am working on it.
Comment 7 Tomasz Morawski 2012-01-27 08:15:49 PST
Created attachment 124320 [details]
First patch

This patch:
- does not change ewk_js file due to that changes for this file are very big. I would like to show this changes in separate patch for this bug or open a new bug.
- does not change realloc operations (separate patch will be prepared).
Comment 8 Gyuyoung Kim 2012-01-30 00:13:10 PST
Comment on attachment 124320 [details]
First patch

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

> Source/WebKit/efl/ewk/ewk_tiled_model.cpp:675
> +            tileUnusedCache->entries.count--;

I think this code should be reviewed by backing store guys.
Comment 9 Tomasz Morawski 2012-02-01 07:14:30 PST
(In reply to comment #8)
> (From update of attachment 124320 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=124320&action=review
> 
> > Source/WebKit/efl/ewk/ewk_tiled_model.cpp:675
> > +            tileUnusedCache->entries.count--;
> 
> I think this code should be reviewed by backing store guys.
It is a very simple change. Patch looks very bad only.
Comment 10 Gyuyoung Kim 2012-02-26 18:12:39 PST
Comment on attachment 124320 [details]
First patch

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

>>> Source/WebKit/efl/ewk/ewk_tiled_model.cpp:675
>>> +            tileUnusedCache->entries.count--;
>> 
>> I think this code should be reviewed by backing store guys.
> 
> It is a very simple change. Patch looks very bad only.

Ok, it looks this patch almost good. If jungjik and Kwanghyuk agree with this patch, this patch is r+ informally.
I think we need to land this patch for EFL port's code quality.

Jungjik and Kwanghyuk, could you review this patch?
Comment 11 Raphael Kubo da Costa (:rakuco) 2012-02-26 18:54:30 PST
Comment on attachment 124320 [details]
First patch

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

Looks good overall, but there are some minor things to work out and you need to rebase it.

> Source/WebKit/efl/ewk/ewk_history.cpp:251
> +    item->title = 0;
> +    item->alternateTitle = 0;
> +    item->uri = 0;
> +    item->originalUri = 0;

How about memset(item, 0, sizeof(*item)) before setting core?

> Source/WebKit/efl/ewk/ewk_tiled_backing_store.cpp:478
> +    OwnPtr<Ewk_Tiled_Backing_Store_Item> item = adoptPtr(new Ewk_Tiled_Backing_Store_Item);

It's safer to #include <OwnPtr.h> in this file.

> Source/WebKit/efl/ewk/ewk_tiled_matrix.cpp:202
> +    OwnPtr<Ewk_Tile_Matrix> tileMatrix = WTF::adoptPtr(new Ewk_Tile_Matrix);

PassOwnPtr.h adds a "using WTF::adoptPtr()" clause, so you can use just adoptPtr the same way you use just OwnPtr.

> Source/WebKit/efl/ewk/ewk_view.cpp:641
> +    priv->settings.encodingDefault = eina_stringshare_add(priv->pageSettings->defaultTextEncodingName().utf8().data());

I'd rather not commit unrelated changes in this patch.
Comment 12 JungJik Lee 2012-02-26 20:30:14 PST
(In reply to comment #10)
> (From update of attachment 124320 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=124320&action=review
> 
> >>> Source/WebKit/efl/ewk/ewk_tiled_model.cpp:675
> >>> +            tileUnusedCache->entries.count--;
> >> 
> >> I think this code should be reviewed by backing store guys.
> > 
> > It is a very simple change. Patch looks very bad only.
> 
> Ok, it looks this patch almost good. If jungjik and Kwanghyuk agree with this patch, this patch is r+ informally.
> I think we need to land this patch for EFL port's code quality.
> 
> Jungjik and Kwanghyuk, could you review this patch?

This part of the code is okay. I think the logic is the same.
Comment 13 Tomasz Morawski 2012-02-27 06:47:22 PST
Created attachment 129031 [details]
Next patch

Fixed Raphael's comments.

Additional change:
I had to left malloc for Ewk_Tile object due to compilation error when "new" was used:

Source/WebKit/efl/ewk/ewk_tiled_model.cpp:189:16: error: uninitialized const member in ‘Ewk_Tile {aka struct _Ewk_Tile}’ using ‘new’ without new-initializer [-fpermissive]
Source/WebKit/efl/ewk/ewk_tiled_backing_store.h:71:22: note: ‘_Ewk_Tile::width’ should be initialized

Anyway, initialization of const fileds in Ewk_Tile looks very ugly. Do you have any good idea to fix this without use of base C++ features like constructor or private section?
Comment 14 Raphael Kubo da Costa (:rakuco) 2012-02-27 15:05:51 PST
Comment on attachment 129031 [details]
Next patch

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

> Source/WebKit/efl/ewk/ewk_tiled_backing_store.cpp:29
> +#include <OwnPtr.h>

You also need PassOwnPtr.h for the implementation of adoptPtr().
Comment 15 Raphael Kubo da Costa (:rakuco) 2012-02-27 15:10:03 PST
(In reply to comment #13)
> Anyway, initialization of const fileds in Ewk_Tile looks very ugly. Do you have any good idea to fix this without use of base C++ features like constructor or private section?

Nope.
Comment 16 Tomasz Morawski 2012-02-28 00:00:02 PST
Created attachment 129201 [details]
Fixed Raphael's comment
Comment 17 Tomasz Morawski 2012-02-28 00:01:37 PST
(In reply to comment #15)
> (In reply to comment #13)
> > Anyway, initialization of const fileds in Ewk_Tile looks very ugly. Do you have any good idea to fix this without use of base C++ features like constructor or private section?
> 
> Nope.
Maybe it is a good point to find a good solution for this and future similar "issues"?
Comment 18 Raphael Kubo da Costa (:rakuco) 2012-02-28 04:36:31 PST
Comment on attachment 129201 [details]
Fixed Raphael's comment

It finally looks OK to me :)
Comment 19 Tomasz Morawski 2012-02-28 23:50:55 PST
(In reply to comment #18)
> (From update of attachment 129201 [details])
> It finally looks OK to me :)
Thanks for infomal review. :)
Comment 20 Hajime Morrita 2012-02-29 00:05:29 PST
Comment on attachment 129201 [details]
Fixed Raphael's comment

I hope these new-allocated structs have a constructor instead of memeset()-ed...
Comment 21 Tomasz Morawski 2012-02-29 00:23:03 PST
(In reply to comment #20)
> (From update of attachment 129201 [details])
> I hope these new-allocated structs have a constructor instead of memeset()-ed...

Currently, fileds are initialized when it is needed in functions that creates object and this patch doesn't changed this way. IMO, missing simple constructor that initialize structure fields could be an issue in EFL port.
Comment 22 WebKit Review Bot 2012-02-29 00:58:44 PST
Comment on attachment 129201 [details]
Fixed Raphael's comment

Clearing flags on attachment: 129201

Committed r109205: <http://trac.webkit.org/changeset/109205>
Comment 23 WebKit Review Bot 2012-02-29 00:58:50 PST
All reviewed patches have been landed.  Closing bug.