Chromium Code Reviews
DescriptionFix incorrect usage of StringImpl::sizeInBytes.
Confusingly StringImpl::sizeInBytes and String::sizeInBytes return totally
different things!
- StringImpl's method returns the size of the storage for the characters *plus* the
size of the StringImpl object overhead.
- String's method returns just the size of the storage for the characters.
This patch makes them both return the size of the storage for the characters which
is actually what everyone wants and renames the method charactersSizeInBytes().
Thankfully the only confused caller was NetworkResourcesData in the inspector.
I also removed the memoryConsumption() method in StringResource which was just
duplicating this method and added a method to AtomicString so it has the same
API as String.
I also switched to size_t for the return value of charactersSizeInBytes() because
the length of a string can be nearly UINT_MAX, and sizeof(UChar) is 2, which
means a very large string could have caused overflow here on 64bit machines.
Finally I fixed a potential integer overflow in StringResource where we were
negating the unsigned value returned from sizeInBytes() and assigning to an int,
then subtracting from it the size of the AtomicString if it exists.
Committed: https://crrev.com/3d24a7c4d0c8ede0dffb89b1e7d9e3340f7e7546
Cr-Commit-Position: refs/heads/master@{#411351}
Patch Set 1 #Patch Set 2 : Fix mojo. #Patch Set 3 : size_teeee #Messages
Total messages: 25 (19 generated)
|