From 1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353 Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Wed, 17 Dec 2008 18:05:15 -0800 Subject: Code drop from //branches/cupcake/...@124589 --- WebCore/platform/text/CString.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'WebCore/platform/text/CString.cpp') diff --git a/WebCore/platform/text/CString.cpp b/WebCore/platform/text/CString.cpp index 4300b29..8e68628 100644 --- a/WebCore/platform/text/CString.cpp +++ b/WebCore/platform/text/CString.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,7 +26,8 @@ #include "config.h" #include "CString.h" -#include "DeprecatedCString.h" + +using std::min; namespace WebCore { @@ -40,17 +41,12 @@ CString::CString(const char* str, unsigned length) init(str, length); } -CString::CString(const DeprecatedCString& str) -{ - init(str.data(), str.length()); -} - void CString::init(const char* str, unsigned length) { if (!str) return; - m_buffer = new CStringBuffer(length + 1); + m_buffer = CStringBuffer::create(length + 1); memcpy(m_buffer->data(), str, length); m_buffer->data()[length] = '\0'; } @@ -72,16 +68,11 @@ unsigned CString::length() const { return m_buffer ? m_buffer->length() - 1 : 0; } - -DeprecatedCString CString::deprecatedCString() const -{ - return DeprecatedCString(data(), length() + 1); -} CString CString::newUninitialized(size_t length, char*& characterBuffer) { CString result; - result.m_buffer = new CStringBuffer(length + 1); + result.m_buffer = CStringBuffer::create(length + 1); char* bytes = result.m_buffer->data(); bytes[length] = '\0'; characterBuffer = bytes; @@ -95,7 +86,7 @@ void CString::copyBufferIfNeeded() int len = m_buffer->length(); RefPtr m_temp = m_buffer; - m_buffer = new CStringBuffer(len); + m_buffer = CStringBuffer::create(len); memcpy(m_buffer->data(), m_temp->data(), len); } @@ -108,4 +99,17 @@ bool operator==(const CString& a, const CString& b) return !strncmp(a.data(), b.data(), min(a.length(), b.length())); } +PassRefPtr CString::releaseBuffer() +{ + if (!m_buffer) + return 0; + + copyBufferIfNeeded(); + + RefPtr result = m_buffer->releaseBuffer(); + m_buffer = 0; + return result.release(); +} + + } -- cgit v1.1