summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/text/CString.cpp
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
commit1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353 (patch)
tree4457a7306ea5acb43fe05bfe0973b1f7faf97ba2 /WebCore/platform/text/CString.cpp
parent9364f22aed35e1a1e9d07c121510f80be3ab0502 (diff)
downloadexternal_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.zip
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.gz
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.bz2
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'WebCore/platform/text/CString.cpp')
-rw-r--r--WebCore/platform/text/CString.cpp34
1 files changed, 19 insertions, 15 deletions
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<CStringBuffer> 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<SharedBuffer> CString::releaseBuffer()
+{
+ if (!m_buffer)
+ return 0;
+
+ copyBufferIfNeeded();
+
+ RefPtr<SharedBuffer> result = m_buffer->releaseBuffer();
+ m_buffer = 0;
+ return result.release();
+}
+
+
}