summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-30 08:57:01 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-30 08:57:01 +0200
commit8f45a259fc9f8180b366cbaccac1af6d368e3b3a (patch)
tree5045baec395404f39728611190925f4ce39c2ae4 /AK
parentdd696e7c75c5fb630d10d0ce37e53d88fecb58a0 (diff)
downloadserenity-8f45a259fc9f8180b366cbaccac1af6d368e3b3a.zip
ByteBuffer: Remove pointer() in favor of data()
We had two ways to get the data inside a ByteBuffer. That was silly.
Diffstat (limited to 'AK')
-rw-r--r--AK/ByteBuffer.h17
-rw-r--r--AK/MappedFile.h4
-rw-r--r--AK/StringBuilder.cpp10
3 files changed, 14 insertions, 17 deletions
diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h
index 3743397d51..cea6f07d0f 100644
--- a/AK/ByteBuffer.h
+++ b/AK/ByteBuffer.h
@@ -43,8 +43,8 @@ public:
bool is_empty() const { return !m_size; }
int size() const { return m_size; }
- u8* pointer() { return m_data; }
- const u8* pointer() const { return m_data; }
+ u8* data() { return m_data; }
+ const u8* data() const { return m_data; }
u8* offset_pointer(int offset) { return m_data + offset; }
const u8* offset_pointer(int offset) const { return m_data + offset; }
@@ -130,11 +130,8 @@ public:
bool is_empty() const { return !m_impl || m_impl->is_empty(); }
int size() const { return m_impl ? m_impl->size() : 0; }
- u8* data() { return pointer(); }
- const u8* data() const { return pointer(); }
-
- u8* pointer() { return m_impl ? m_impl->pointer() : nullptr; }
- const u8* pointer() const { return m_impl ? m_impl->pointer() : nullptr; }
+ u8* data() { return m_impl ? m_impl->data() : nullptr; }
+ const u8* data() const { return m_impl ? m_impl->data() : nullptr; }
u8* offset_pointer(int offset) { return m_impl ? m_impl->offset_pointer(offset) : nullptr; }
const u8* offset_pointer(int offset) const { return m_impl ? m_impl->offset_pointer(offset) : nullptr; }
@@ -146,7 +143,7 @@ public:
{
if (!m_impl)
return {};
- return copy(m_impl->pointer(), m_impl->size());
+ return copy(m_impl->data(), m_impl->size());
}
// NOTE: trim() does not reallocate.
@@ -190,7 +187,7 @@ public:
{
int old_size = size();
grow(size() + data_size);
- memcpy(pointer() + old_size, data, data_size);
+ memcpy(this->data() + old_size, data, data_size);
}
private:
@@ -249,7 +246,7 @@ inline NonnullRefPtr<ByteBufferImpl> ByteBufferImpl::create_uninitialized(int si
inline NonnullRefPtr<ByteBufferImpl> ByteBufferImpl::create_zeroed(int size)
{
auto buffer = ::adopt(*new ByteBufferImpl(size));
- memset(buffer->pointer(), 0, size);
+ memset(buffer->data(), 0, size);
return buffer;
}
diff --git a/AK/MappedFile.h b/AK/MappedFile.h
index 913716e365..41e12eb523 100644
--- a/AK/MappedFile.h
+++ b/AK/MappedFile.h
@@ -18,8 +18,8 @@ public:
bool is_valid() const { return m_map != (void*)-1; }
void unmap();
- void* pointer() { return m_map; }
- const void* pointer() const { return m_map; }
+ void* data() { return m_map; }
+ const void* data() const { return m_map; }
size_t size() const { return m_size; }
private:
diff --git a/AK/StringBuilder.cpp b/AK/StringBuilder.cpp
index b692bd4a4d..54100029ff 100644
--- a/AK/StringBuilder.cpp
+++ b/AK/StringBuilder.cpp
@@ -21,7 +21,7 @@ void StringBuilder::append(const StringView& str)
if (str.is_empty())
return;
will_append(str.length());
- memcpy(m_buffer.pointer() + m_length, str.characters_without_null_termination(), str.length());
+ memcpy(m_buffer.data() + m_length, str.characters_without_null_termination(), str.length());
m_length += str.length();
}
@@ -30,14 +30,14 @@ void StringBuilder::append(const char* characters, int length)
if (!length)
return;
will_append(length);
- memcpy(m_buffer.pointer() + m_length, characters, length);
+ memcpy(m_buffer.data() + m_length, characters, length);
m_length += length;
}
void StringBuilder::append(char ch)
{
will_append(1);
- m_buffer.pointer()[m_length] = ch;
+ m_buffer.data()[m_length] = ch;
m_length += 1;
}
@@ -67,14 +67,14 @@ ByteBuffer StringBuilder::to_byte_buffer()
String StringBuilder::to_string()
{
- auto string = String((const char*)m_buffer.pointer(), m_length);
+ auto string = String((const char*)m_buffer.data(), m_length);
clear();
return string;
}
StringView StringBuilder::string_view() const
{
- return StringView { (const char*)m_buffer.pointer(), m_length };
+ return StringView { (const char*)m_buffer.data(), m_length };
}
void StringBuilder::clear()