| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 void ArrayBufferContents::copyTo(ArrayBufferContents& other) | 95 void ArrayBufferContents::copyTo(ArrayBufferContents& other) |
| 96 { | 96 { |
| 97 ASSERT(!m_holder->isShared() && !other.m_holder->isShared()); | 97 ASSERT(!m_holder->isShared() && !other.m_holder->isShared()); |
| 98 m_holder->copyMemoryTo(*other.m_holder); | 98 m_holder->copyMemoryTo(*other.m_holder); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void ArrayBufferContents::allocateMemory(size_t size, InitializationPolicy polic
y, void*& data) | 101 void ArrayBufferContents::allocateMemory(size_t size, InitializationPolicy polic
y, void*& data) |
| 102 { | 102 { |
| 103 if (s_adjustAmountOfExternalAllocatedMemoryFunction) | 103 if (s_adjustAmountOfExternalAllocatedMemoryFunction) |
| 104 s_adjustAmountOfExternalAllocatedMemoryFunction(static_cast<int>(size)); | 104 s_adjustAmountOfExternalAllocatedMemoryFunction(static_cast<int>(size)); |
| 105 data = partitionAllocGenericFlags(WTF::Partitions::bufferPartition(), Partit
ionAllocReturnNull, size); | 105 data = partitionAllocGeneric(WTF::Partitions::bufferPartition(), size); |
| 106 if (policy == ZeroInitialize && data) | 106 if (policy == ZeroInitialize && data) |
| 107 memset(data, '\0', size); | 107 memset(data, '\0', size); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void ArrayBufferContents::freeMemory(void* data, size_t size) | 110 void ArrayBufferContents::freeMemory(void* data, size_t size) |
| 111 { | 111 { |
| 112 Partitions::bufferFree(data); | 112 Partitions::bufferFree(data); |
| 113 if (s_adjustAmountOfExternalAllocatedMemoryFunction) | 113 if (s_adjustAmountOfExternalAllocatedMemoryFunction) |
| 114 s_adjustAmountOfExternalAllocatedMemoryFunction(-static_cast<int>(size))
; | 114 s_adjustAmountOfExternalAllocatedMemoryFunction(-static_cast<int>(size))
; |
| 115 } | 115 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 ASSERT(!other.m_sizeInBytes); | 151 ASSERT(!other.m_sizeInBytes); |
| 152 ArrayBufferContents::freeMemory(other.m_data, other.m_sizeInBytes); | 152 ArrayBufferContents::freeMemory(other.m_data, other.m_sizeInBytes); |
| 153 ArrayBufferContents::allocateMemory(m_sizeInBytes, DontInitialize, other.m_d
ata); | 153 ArrayBufferContents::allocateMemory(m_sizeInBytes, DontInitialize, other.m_d
ata); |
| 154 if (!other.m_data) | 154 if (!other.m_data) |
| 155 return; | 155 return; |
| 156 memcpy(other.m_data, m_data, m_sizeInBytes); | 156 memcpy(other.m_data, m_data, m_sizeInBytes); |
| 157 other.m_sizeInBytes = m_sizeInBytes; | 157 other.m_sizeInBytes = m_sizeInBytes; |
| 158 } | 158 } |
| 159 | 159 |
| 160 } // namespace WTF | 160 } // namespace WTF |
| OLD | NEW |