| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // No need to use segments for small resource data. | 102 // No need to use segments for small resource data. |
| 103 m_buffer.append(data, length); | 103 m_buffer.append(data, length); |
| 104 return; | 104 return; |
| 105 } | 105 } |
| 106 | 106 |
| 107 char* segment; | 107 char* segment; |
| 108 if (!positionInSegment) { | 108 if (!positionInSegment) { |
| 109 segment = allocateSegment(); | 109 segment = allocateSegment(); |
| 110 m_segments.append(segment); | 110 m_segments.append(segment); |
| 111 } else | 111 } else |
| 112 segment = m_segments.last() + positionInSegment; | 112 segment = m_segments.back() + positionInSegment; |
| 113 | 113 |
| 114 size_t segmentFreeSpace = kSegmentSize - positionInSegment; | 114 size_t segmentFreeSpace = kSegmentSize - positionInSegment; |
| 115 size_t bytesToCopy = std::min(length, segmentFreeSpace); | 115 size_t bytesToCopy = std::min(length, segmentFreeSpace); |
| 116 | 116 |
| 117 for (;;) { | 117 for (;;) { |
| 118 memcpy(segment, data, bytesToCopy); | 118 memcpy(segment, data, bytesToCopy); |
| 119 if (length == bytesToCopy) | 119 if (length == bytesToCopy) |
| 120 break; | 120 break; |
| 121 | 121 |
| 122 length -= bytesToCopy; | 122 length -= bytesToCopy; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 // using fastMalloc. | 260 // using fastMalloc. |
| 261 const String dataDumpName = dumpPrefix + "/segments"; | 261 const String dataDumpName = dumpPrefix + "/segments"; |
| 262 auto dump = memoryDump->createMemoryAllocatorDump(dataDumpName); | 262 auto dump = memoryDump->createMemoryAllocatorDump(dataDumpName); |
| 263 dump->addScalar("size", "bytes", m_size); | 263 dump->addScalar("size", "bytes", m_size); |
| 264 memoryDump->addSuballocation( | 264 memoryDump->addSuballocation( |
| 265 dump->guid(), String(WTF::Partitions::kAllocatedObjectPoolName)); | 265 dump->guid(), String(WTF::Partitions::kAllocatedObjectPoolName)); |
| 266 } | 266 } |
| 267 } | 267 } |
| 268 | 268 |
| 269 } // namespace blink | 269 } // namespace blink |
| OLD | NEW |