[Webkit-unassigned] [Bug 20422] Patch to allow custom memory allocation control

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Dec 3 12:39:34 PST 2008


https://bugs.webkit.org/show_bug.cgi?id=20422





------- Comment #38 from darin at apple.com  2008-12-03 12:39 PDT -------
(In reply to comment #37)
>     >> -  do_free(ptr);
>     >> +  free(ptr);
>     >>  }
> 
>     > Do you really need to change this?
> 
> I believe, the former behavior is a bug, as it bypasses the InvokeDeleteHook
> mechanism. cfree is a sibling to free and a complement to calloc. Without the
> above fix, a call to calloc would result in a call to InvokeNewHook, but the
> eventual call to cfree would never call the InvokeDeleteHook.

OK. Lets fix this separately, then. Doesn't seem closely related to the rest of
what's going on here.

>     >>    if (new_size == 0) {
>     >> -#ifndef WTF_CHANGES
>     >> -    MallocHook::InvokeDeleteHook(old_ptr);
>     >> -#endif
>     >>      free(old_ptr);
>     >>      return NULL;
>     >>    }
> 
>     > I don't understand what the value is of removing InvokeDeleteHook here.
> 
> The InvokeDeleteHook call is redundant and is called again within free. Aside
> from being less efficient, it complicates the user's implementation
> requirements and makes it harder to do validation since the user would have to
> keep track of pointers being 'double-deleted'.
> 
> If for some reason people want to keep the existing (IMO buggy) behavior, then
> I can undo the above.

Same comment. Lets fix these without including all the other changes.

>     >> I don't understand how you can store both the array size and
>     >> the validation type in the same place; "p" and "a.size" both point
>     >> to the same address. Maybe I'm missing something obvious here.
> 
> They aren't stored in the same place. The validation type is stored prior
> in memory to the array size. First the validation type is written in some
> reserved prefix bytes, then the array size is written in its own reserved
> prefix bytes. The array code doesn't care about the location of the
> validation type bytes. The unit tests exercise this and execute OK, FWIW.

There are two ways to resolve this then:

    1) Make me smarter.
    2) Make the code easier to read.

Somehow I thought that "p" and "a.size" were the same address. I'm just
guessing, but there's probably a way to write this that makes it clearer.


-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list