diff options
Diffstat (limited to 'Source/WebCore/platform/cf/SharedBufferCF.cpp')
-rw-r--r-- | Source/WebCore/platform/cf/SharedBufferCF.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Source/WebCore/platform/cf/SharedBufferCF.cpp b/Source/WebCore/platform/cf/SharedBufferCF.cpp index 18a65c2..319f484 100644 --- a/Source/WebCore/platform/cf/SharedBufferCF.cpp +++ b/Source/WebCore/platform/cf/SharedBufferCF.cpp @@ -91,4 +91,30 @@ void SharedBuffer::clearPlatformData() m_cfData = 0; } +#if HAVE(CFNETWORK_DATA_ARRAY_CALLBACK) +void SharedBuffer::append(CFDataRef data) +{ + ASSERT(data); + m_dataArray.append(data); + m_size += CFDataGetLength(data); +} + +void SharedBuffer::copyDataArrayAndClear(char *destination, unsigned bytesToCopy) const +{ + if (m_dataArray.isEmpty()) + return; + + CFIndex bytesLeft = bytesToCopy; + Vector<RetainPtr<CFDataRef> >::const_iterator end = m_dataArray.end(); + for (Vector<RetainPtr<CFDataRef> >::const_iterator it = m_dataArray.begin(); it != end; ++it) { + CFIndex dataLen = CFDataGetLength(it->get()); + ASSERT(bytesLeft >= dataLen); + memcpy(destination, CFDataGetBytePtr(it->get()), dataLen); + destination += dataLen; + bytesLeft -= dataLen; + } + m_dataArray.clear(); +} +#endif + } |