WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
123955
Avoid calling fastRealloc when it returns the same address
https://bugs.webkit.org/show_bug.cgi?id=123955
Summary
Avoid calling fastRealloc when it returns the same address
Hironori Bono
Reported
2013-11-06 22:19:05 PST
Created
attachment 216259
[details]
A patch that uses fastMallocGoodSize Greetings, On OS X, malloc() rounds up the specified size to a multiple of malloc_good_size(). (For example, malloc(1) returns a 16-byte block on OS X.) Also, as listed in the source code <
http://www.opensource.apple.com/source/Libc/Libc-594.1.4/gen/malloc.c
>, realloc() returns the same address when the specified new size is less than the block size of the given memory, i.e. |p0| is equal to |p1| in the following code snippet. int main(int argc, char* argv[]) { void* p0 = malloc(1); void* p1 = realloc(p0, 10); printf("p0=%p, p1=%p\n", p0, p1); return 0; } To consider this fact, it may be good for the StringBuilder class to use fastMallocGoodSize(length) instead of length to check if it needs to call StringBuilder<T>::reallocateBuffer() as listed in the attached diff. (For your information, the StringBUilder class tried reallocating memory to the same block size >13000 times when I ran 'run-webkit-tests --no-http' on my Mac.) Regards, Hironori Bono
Attachments
A patch that uses fastMallocGoodSize
(2.72 KB, patch)
2013-11-06 22:19 PST
,
Hironori Bono
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug