diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h index 3743397d512715..cea6f07d0f4979 100644 --- a/AK/ByteBuffer.h +++ b/AK/ByteBuffer.h @@ -43,8 +43,8 @@ class ByteBufferImpl : public RefCounted { 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 @@ class ByteBuffer { 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 @@ class ByteBuffer { { 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 @@ class ByteBuffer { { 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::create_uninitialized(int si inline NonnullRefPtr 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 913716e365a62d..41e12eb523b6e8 100644 --- a/AK/MappedFile.h +++ b/AK/MappedFile.h @@ -18,8 +18,8 @@ class MappedFile { 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 b692bd4a4db091..54100029ffad5d 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() diff --git a/Applications/Downloader/main.cpp b/Applications/Downloader/main.cpp index 6d8fbffdee15dd..4cee5a43877ca0 100644 --- a/Applications/Downloader/main.cpp +++ b/Applications/Downloader/main.cpp @@ -20,7 +20,7 @@ int main(int argc, char** argv) auto& response = static_cast(*job->response()); printf("%s{%p}: on_receive: code=%d\n", job->class_name(), job.ptr(), response.code()); //printf("payload:\n"); - //printf("%s", response.payload().pointer()); + //printf("%s", response.payload().data()); printf("payload was %d bytes\n", response.payload().size()); }; diff --git a/Kernel/Devices/PATAChannel.cpp b/Kernel/Devices/PATAChannel.cpp index 7e24db3284ad55..4d78562a8da9dd 100644 --- a/Kernel/Devices/PATAChannel.cpp +++ b/Kernel/Devices/PATAChannel.cpp @@ -207,9 +207,9 @@ void PATAChannel::detect_disks() ByteBuffer wbuf = ByteBuffer::create_uninitialized(512); ByteBuffer bbuf = ByteBuffer::create_uninitialized(512); - u8* b = bbuf.pointer(); - u16* w = (u16*)wbuf.pointer(); - const u16* wbufbase = (u16*)wbuf.pointer(); + u8* b = bbuf.data(); + u16* w = (u16*)wbuf.data(); + const u16* wbufbase = (u16*)wbuf.data(); for (u32 i = 0; i < 256; ++i) { u16 data = IO::in16(m_io_base + ATA_REG_DATA); @@ -228,7 +228,7 @@ void PATAChannel::detect_disks() kprintf( "PATAChannel: Name=\"%s\", C/H/Spt=%u/%u/%u\n", - bbuf.pointer() + 54, + bbuf.data() + 54, cyls, heads, spt); diff --git a/Kernel/FileSystem/DiskBackedFileSystem.cpp b/Kernel/FileSystem/DiskBackedFileSystem.cpp index 51b193f3b8b0e0..59d51ff4b4ef11 100644 --- a/Kernel/FileSystem/DiskBackedFileSystem.cpp +++ b/Kernel/FileSystem/DiskBackedFileSystem.cpp @@ -107,7 +107,7 @@ ByteBuffer DiskBackedFS::read_block(unsigned index) const auto buffer = ByteBuffer::create_uninitialized(block_size()); //kprintf("created block buffer with size %u\n", block_size()); DiskOffset base_offset = static_cast(index) * static_cast(block_size()); - auto* buffer_pointer = buffer.pointer(); + auto* buffer_pointer = buffer.data(); bool success = device().read(base_offset, block_size(), buffer_pointer); ASSERT(success); ASSERT(buffer.size() == block_size()); @@ -126,13 +126,13 @@ ByteBuffer DiskBackedFS::read_blocks(unsigned index, unsigned count) const if (count == 1) return read_block(index); auto blocks = ByteBuffer::create_uninitialized(count * block_size()); - u8* out = blocks.pointer(); + u8* out = blocks.data(); for (unsigned i = 0; i < count; ++i) { auto block = read_block(index + i); if (!block) return nullptr; - memcpy(out, block.pointer(), block.size()); + memcpy(out, block.data(), block.size()); out += block_size(); } diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index af6d0b391517ee..acf58402909971 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -49,7 +49,7 @@ ByteBuffer Ext2FS::read_super_block() const { LOCKER(m_lock); auto buffer = ByteBuffer::create_uninitialized(1024); - bool success = device().read_block(2, buffer.pointer()); + bool success = device().read_block(2, buffer.data()); ASSERT(success); success = device().read_block(3, buffer.offset_pointer(512)); ASSERT(success); @@ -79,7 +79,7 @@ const ext2_super_block& Ext2FS::super_block() const { if (!m_cached_super_block) m_cached_super_block = read_super_block(); - return *reinterpret_cast(m_cached_super_block.pointer()); + return *reinterpret_cast(m_cached_super_block.data()); } const ext2_group_desc& Ext2FS::group_descriptor(GroupIndex group_index) const @@ -97,7 +97,7 @@ const ext2_group_desc& Ext2FS::group_descriptor(GroupIndex group_index) const #endif m_cached_group_descriptor_table = read_blocks(first_block_of_bgdt, blocks_to_read); } - return reinterpret_cast(m_cached_group_descriptor_table.pointer())[group_index - 1]; + return reinterpret_cast(m_cached_group_descriptor_table.data())[group_index - 1]; } bool Ext2FS::initialize() @@ -321,10 +321,10 @@ bool Ext2FS::write_block_list_for_inode(InodeIndex inode_index, ext2_inode& e2in auto dind_block_contents = read_block(e2inode.i_block[EXT2_DIND_BLOCK]); if (dind_block_new) { - memset(dind_block_contents.pointer(), 0, dind_block_contents.size()); + memset(dind_block_contents.data(), 0, dind_block_contents.size()); dind_block_dirty = true; } - auto* dind_block_as_pointers = (unsigned*)dind_block_contents.pointer(); + auto* dind_block_as_pointers = (unsigned*)dind_block_contents.data(); ASSERT(indirect_block_count <= entries_per_block); for (unsigned i = 0; i < indirect_block_count; ++i) { @@ -341,10 +341,10 @@ bool Ext2FS::write_block_list_for_inode(InodeIndex inode_index, ext2_inode& e2in auto ind_block_contents = read_block(indirect_block_index); if (ind_block_new) { - memset(ind_block_contents.pointer(), 0, dind_block_contents.size()); + memset(ind_block_contents.data(), 0, dind_block_contents.size()); ind_block_dirty = true; } - auto* ind_block_as_pointers = (unsigned*)ind_block_contents.pointer(); + auto* ind_block_as_pointers = (unsigned*)ind_block_contents.data(); unsigned entries_to_write = new_shape.doubly_indirect_blocks - (i * entries_per_block); if (entries_to_write > entries_per_block) @@ -430,7 +430,7 @@ Vector Ext2FS::block_list_for_inode(const ext2_inode& e2inod callback(array_block_index); auto array_block = read_block(array_block_index); ASSERT(array_block); - auto* array = reinterpret_cast(array_block.pointer()); + auto* array = reinterpret_cast(array_block.data()); unsigned count = min(blocks_remaining, entries_per_block); for (unsigned i = 0; i < count; ++i) { if (!array[i]) { @@ -646,7 +646,7 @@ ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, u8* buffer, FileDes int offset_into_block = (bi == first_block_logical_index) ? offset_into_first_block : 0; int num_bytes_to_copy = min(block_size - offset_into_block, remaining_count); - memcpy(out, block.pointer() + offset_into_block, num_bytes_to_copy); + memcpy(out, block.data() + offset_into_block, num_bytes_to_copy); remaining_count -= num_bytes_to_copy; nread += num_bytes_to_copy; out += num_bytes_to_copy; @@ -755,14 +755,14 @@ ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const u8* data, Fi } else block = buffer_block; - memcpy(block.pointer() + offset_into_block, in, num_bytes_to_copy); + memcpy(block.data() + offset_into_block, in, num_bytes_to_copy); if (bi == last_logical_block_index_in_file && num_bytes_to_copy < block_size) { int padding_start = new_size % block_size; int padding_bytes = block_size - padding_start; #ifdef EXT2_DEBUG dbgprintf("Ext2FSInode::write_bytes padding last block of file with zero x %u (new_size=%u, offset_into_block=%u, num_bytes_to_copy=%u)\n", padding_bytes, new_size, offset_into_block, num_bytes_to_copy); #endif - memset(block.pointer() + padding_start, 0, padding_bytes); + memset(block.data() + padding_start, 0, padding_bytes); } #ifdef EXT2_DEBUG dbgprintf("Ext2FSInode::write_bytes: writing block %u (offset_into_block: %u)\n", m_block_list[bi], offset_into_block); @@ -799,7 +799,7 @@ bool Ext2FSInode::traverse_as_directory(Function(buffer.pointer()); + auto* entry = reinterpret_cast(buffer.data()); while (entry < buffer.end_pointer()) { if (entry->inode != 0) { @@ -867,7 +867,7 @@ bool Ext2FSInode::write_directory(const Vector& entries) stream.fill_to_end(0); - ssize_t nwritten = write_bytes(0, directory_data.size(), directory_data.pointer(), nullptr); + ssize_t nwritten = write_bytes(0, directory_data.size(), directory_data.data(), nullptr); return nwritten == directory_data.size(); } @@ -1006,7 +1006,7 @@ Ext2FS::BlockIndex Ext2FS::allocate_block(GroupIndex preferred_group_index) auto bitmap_block = read_block(bgd.bg_block_bitmap); int blocks_in_group = min(blocks_per_group(), super_block().s_blocks_count); - auto block_bitmap = Bitmap::wrap(bitmap_block.pointer(), blocks_in_group); + auto block_bitmap = Bitmap::wrap(bitmap_block.data(), blocks_in_group); BlockIndex first_block_in_group = (group_index - 1) * blocks_per_group() + first_block_index(); int first_unset_bit_index = block_bitmap.find_first_unset(); ASSERT(first_unset_bit_index != -1); @@ -1136,7 +1136,7 @@ bool Ext2FS::get_inode_allocation_state(InodeIndex index) const unsigned bit_index = (index_in_group - 1) % inodes_per_group(); auto block = read_block(bgd.bg_inode_bitmap); ASSERT(block); - auto bitmap = Bitmap::wrap(block.pointer(), inodes_per_group()); + auto bitmap = Bitmap::wrap(block.data(), inodes_per_group()); return bitmap.get(bit_index); } @@ -1149,7 +1149,7 @@ bool Ext2FS::set_inode_allocation_state(InodeIndex inode_index, bool new_state) unsigned bit_index = (index_in_group - 1) % inodes_per_group(); auto block = read_block(bgd.bg_inode_bitmap); ASSERT(block); - auto bitmap = Bitmap::wrap(block.pointer(), inodes_per_group()); + auto bitmap = Bitmap::wrap(block.data(), inodes_per_group()); bool current_state = bitmap.get(bit_index); #ifdef EXT2_DEBUG dbgprintf("Ext2FS: set_inode_allocation_state(%u) %u -> %u\n", inode_index, current_state, new_state); @@ -1165,7 +1165,7 @@ bool Ext2FS::set_inode_allocation_state(InodeIndex inode_index, bool new_state) ASSERT(success); // Update superblock - auto& sb = *reinterpret_cast(m_cached_super_block.pointer()); + auto& sb = *reinterpret_cast(m_cached_super_block.data()); #ifdef EXT2_DEBUG dbgprintf("Ext2FS: superblock free inode count %u -> %u\n", sb.s_free_inodes_count, sb.s_free_inodes_count - 1); #endif @@ -1212,7 +1212,7 @@ bool Ext2FS::set_block_allocation_state(BlockIndex block_index, bool new_state) #endif auto block = read_block(bgd.bg_block_bitmap); ASSERT(block); - auto bitmap = Bitmap::wrap(block.pointer(), blocks_per_group()); + auto bitmap = Bitmap::wrap(block.data(), blocks_per_group()); bool current_state = bitmap.get(bit_index); #ifdef EXT2_DEBUG dbgprintf("Ext2FS: block %u state: %u -> %u\n", block_index, current_state, new_state); @@ -1228,7 +1228,7 @@ bool Ext2FS::set_block_allocation_state(BlockIndex block_index, bool new_state) ASSERT(success); // Update superblock - auto& sb = *reinterpret_cast(m_cached_super_block.pointer()); + auto& sb = *reinterpret_cast(m_cached_super_block.data()); #ifdef EXT2_DEBUG dbgprintf("Ext2FS: superblock free block count %u -> %u\n", sb.s_free_blocks_count, sb.s_free_blocks_count - 1); #endif diff --git a/Kernel/FileSystem/FileDescription.cpp b/Kernel/FileSystem/FileDescription.cpp index 5d238cea88cde3..defb5e6338d131 100644 --- a/Kernel/FileSystem/FileDescription.cpp +++ b/Kernel/FileSystem/FileDescription.cpp @@ -168,7 +168,7 @@ ssize_t FileDescription::get_dir_entries(u8* buffer, ssize_t size) if (size < temp_buffer.size()) return -1; - memcpy(buffer, temp_buffer.pointer(), temp_buffer.size()); + memcpy(buffer, temp_buffer.data(), temp_buffer.size()); return stream.offset(); } diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index ba5819412d62ee..397056866cb574 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -796,7 +796,7 @@ static ssize_t write_sys_string(InodeIdentifier inode_id, const ByteBuffer& data { auto* lockable_string = reinterpret_cast*>(variable.address); LOCKER(lockable_string->lock()); - lockable_string->resource() = String((const char*)data.pointer(), data.size()); + lockable_string->resource() = String((const char*)data.data(), data.size()); } variable.notify(); return data.size(); diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index 14a278d779dc74..d4daeed10e04ea 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -714,7 +714,7 @@ KResultOr> VFS::resolve_path(StringView path, Custody& ba // FIXME: We should limit the recursion here and return -ELOOP if it goes to deep. auto symlink_target = resolve_path( - StringView(symlink_contents.pointer(), + StringView(symlink_contents.data(), symlink_contents.size()), current_parent, parent_custody, diff --git a/Kernel/KSyms.cpp b/Kernel/KSyms.cpp index 77498f8daf634a..9e99a8f19241f5 100644 --- a/Kernel/KSyms.cpp +++ b/Kernel/KSyms.cpp @@ -34,7 +34,7 @@ static void load_ksyms_from_data(const ByteBuffer& buffer) { ksym_lowest_address = 0xffffffff; ksym_highest_address = 0; - auto* bufptr = (const char*)buffer.pointer(); + auto* bufptr = (const char*)buffer.data(); auto* start_of_name = bufptr; u32 address = 0; diff --git a/Kernel/Net/NetworkAdapter.cpp b/Kernel/Net/NetworkAdapter.cpp index 8c8dedbbdd28bd..b1617109b4bcf2 100644 --- a/Kernel/Net/NetworkAdapter.cpp +++ b/Kernel/Net/NetworkAdapter.cpp @@ -58,7 +58,7 @@ void NetworkAdapter::send(const MACAddress& destination, const ARPPacket& packet { int size_in_bytes = sizeof(EthernetFrameHeader) + sizeof(ARPPacket); auto buffer = ByteBuffer::create_zeroed(size_in_bytes); - auto* eth = (EthernetFrameHeader*)buffer.pointer(); + auto* eth = (EthernetFrameHeader*)buffer.data(); eth->set_source(mac_address()); eth->set_destination(destination); eth->set_ether_type(EtherType::ARP); @@ -72,7 +72,7 @@ void NetworkAdapter::send_ipv4(const MACAddress& destination_mac, const IPv4Addr { size_t size_in_bytes = sizeof(EthernetFrameHeader) + sizeof(IPv4Packet) + payload_size; auto buffer = ByteBuffer::create_zeroed(size_in_bytes); - auto& eth = *(EthernetFrameHeader*)buffer.pointer(); + auto& eth = *(EthernetFrameHeader*)buffer.data(); eth.set_source(mac_address()); eth.set_destination(destination_mac); eth.set_ether_type(EtherType::IPv4); diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp index bce343364f80e0..1799c6ac98c59c 100644 --- a/Kernel/Net/NetworkTask.cpp +++ b/Kernel/Net/NetworkTask.cpp @@ -264,7 +264,7 @@ void handle_icmp(const EthernetFrameHeader& eth, const IPv4Packet& ipv4_packet) (u16)request.sequence_number); size_t icmp_packet_size = ipv4_packet.payload_size(); auto buffer = ByteBuffer::create_zeroed(icmp_packet_size); - auto& response = *(ICMPEchoPacket*)buffer.pointer(); + auto& response = *(ICMPEchoPacket*)buffer.data(); response.header.set_type(ICMPType::EchoReply); response.header.set_code(0); response.identifier = request.identifier; diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp index 8be47ed526d4a6..b82ab4338962ef 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -140,7 +140,7 @@ int TCPSocket::protocol_send(const void* data, int data_length) void TCPSocket::send_tcp_packet(u16 flags, const void* payload, int payload_size) { auto buffer = ByteBuffer::create_zeroed(sizeof(TCPPacket) + payload_size); - auto& tcp_packet = *(TCPPacket*)(buffer.pointer()); + auto& tcp_packet = *(TCPPacket*)(buffer.data()); ASSERT(local_port()); tcp_packet.set_source_port(local_port()); tcp_packet.set_destination_port(peer_port()); @@ -194,7 +194,7 @@ void TCPSocket::send_outgoing_packets() packet.tx_counter++; #ifdef TCP_SOCKET_DEBUG - auto& tcp_packet = *(TCPPacket*)(packet.buffer.pointer()); + auto& tcp_packet = *(TCPPacket*)(packet.buffer.data()); kprintf("sending tcp packet from %s:%u to %s:%u with (%s%s%s%s) seq_no=%u, ack_no=%u, tx_counter=%u\n", local_address().to_string().characters(), local_port(), diff --git a/Kernel/Net/UDPSocket.cpp b/Kernel/Net/UDPSocket.cpp index 103c8242260c8c..8d3890f6ab5f6c 100644 --- a/Kernel/Net/UDPSocket.cpp +++ b/Kernel/Net/UDPSocket.cpp @@ -67,7 +67,7 @@ int UDPSocket::protocol_send(const void* data, int data_length) if (routing_decision.is_zero()) return -EHOSTUNREACH; auto buffer = ByteBuffer::create_zeroed(sizeof(UDPPacket) + data_length); - auto& udp_packet = *(UDPPacket*)(buffer.pointer()); + auto& udp_packet = *(UDPPacket*)(buffer.data()); udp_packet.set_source_port(local_port()); udp_packet.set_destination_port(peer_port()); udp_packet.set_length(sizeof(UDPPacket) + data_length); diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index f4cbdbc3af4f90..c82ac013577cd4 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -1240,7 +1240,7 @@ int Process::sys$readlink(const char* path, char* buffer, ssize_t size) if (!contents) return -EIO; // FIXME: Get a more detailed error from VFS. - memcpy(buffer, contents.pointer(), min(size, (ssize_t)contents.size())); + memcpy(buffer, contents.data(), min(size, (ssize_t)contents.size())); if (contents.size() + 1 < size) buffer[contents.size()] = '\0'; return 0; diff --git a/Libraries/LibCore/CConfigFile.cpp b/Libraries/LibCore/CConfigFile.cpp index 7d53a270444448..3b7ddfa144eccc 100644 --- a/Libraries/LibCore/CConfigFile.cpp +++ b/Libraries/LibCore/CConfigFile.cpp @@ -44,7 +44,7 @@ void CConfigFile::reparse() while (file->can_read_line()) { auto line = file->read_line(BUFSIZ); - auto* cp = (const char*)line.pointer(); + auto* cp = (const char*)line.data(); while (*cp && (*cp == ' ' || *cp == '\t' || *cp == '\n')) ++cp; diff --git a/Libraries/LibCore/CHttpJob.cpp b/Libraries/LibCore/CHttpJob.cpp index 1548ada8ae170c..b1605f36aefd63 100644 --- a/Libraries/LibCore/CHttpJob.cpp +++ b/Libraries/LibCore/CHttpJob.cpp @@ -38,7 +38,7 @@ void CHttpJob::on_socket_connected() } auto parts = String::copy(line, Chomp).split(' '); if (parts.size() < 3) { - fprintf(stderr, "CHttpJob: Expected 3-part HTTP status, got '%s'\n", line.pointer()); + fprintf(stderr, "CHttpJob: Expected 3-part HTTP status, got '%s'\n", line.data()); return deferred_invoke([this](auto&) { did_fail(CNetworkJob::Error::ProtocolFailed); }); } bool ok; diff --git a/Libraries/LibCore/CIODevice.cpp b/Libraries/LibCore/CIODevice.cpp index 2098d7ee5ae306..b0f6148563ca43 100644 --- a/Libraries/LibCore/CIODevice.cpp +++ b/Libraries/LibCore/CIODevice.cpp @@ -38,7 +38,7 @@ ByteBuffer CIODevice::read(int max_size) if (!max_size) return {}; auto buffer = ByteBuffer::create_uninitialized(max_size); - auto* buffer_ptr = (char*)buffer.pointer(); + auto* buffer_ptr = (char*)buffer.data(); int remaining_buffer_space = buffer.size(); int taken_from_buffered = 0; if (!m_buffered_data.is_empty()) { diff --git a/Libraries/LibCore/CSocket.cpp b/Libraries/LibCore/CSocket.cpp index 7ac939e7804be6..f652274b2e0ae7 100644 --- a/Libraries/LibCore/CSocket.cpp +++ b/Libraries/LibCore/CSocket.cpp @@ -119,7 +119,7 @@ ByteBuffer CSocket::receive(int max_size) bool CSocket::send(const ByteBuffer& data) { - int nsent = ::send(fd(), data.pointer(), data.size(), 0); + int nsent = ::send(fd(), data.data(), data.size(), 0); if (nsent < 0) { set_error(errno); return false; diff --git a/Libraries/LibDraw/Font.cpp b/Libraries/LibDraw/Font.cpp index be6bf6e462b61b..bd5152076579ba 100644 --- a/Libraries/LibDraw/Font.cpp +++ b/Libraries/LibDraw/Font.cpp @@ -134,7 +134,7 @@ RefPtr Font::load_from_file(const StringView& path) if (!mapped_file.is_valid()) return nullptr; - auto font = load_from_memory((const u8*)mapped_file.pointer()); + auto font = load_from_memory((const u8*)mapped_file.data()); font->m_mapped_file = move(mapped_file); return font; } @@ -166,7 +166,7 @@ bool Font::write_to_file(const StringView& path) stream << ByteBuffer::wrap(m_glyph_widths, 256); ASSERT(stream.at_end()); - ssize_t nwritten = write(fd, buffer.pointer(), buffer.size()); + ssize_t nwritten = write(fd, buffer.data(), buffer.size()); ASSERT(nwritten == (ssize_t)buffer.size()); int rc = close(fd); ASSERT(rc == 0); diff --git a/Libraries/LibDraw/GraphicsBitmap.cpp b/Libraries/LibDraw/GraphicsBitmap.cpp index b09996761daf29..7941b0a338b930 100644 --- a/Libraries/LibDraw/GraphicsBitmap.cpp +++ b/Libraries/LibDraw/GraphicsBitmap.cpp @@ -54,7 +54,7 @@ GraphicsBitmap::GraphicsBitmap(Format format, const Size& size, size_t pitch, RG GraphicsBitmap::GraphicsBitmap(Format format, const Size& size, MappedFile&& mapped_file) : m_size(size) - , m_data((RGBA32*)mapped_file.pointer()) + , m_data((RGBA32*)mapped_file.data()) , m_pitch(round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16)) , m_format(format) , m_mapped_file(move(mapped_file)) diff --git a/Libraries/LibDraw/PNGLoader.cpp b/Libraries/LibDraw/PNGLoader.cpp index 1ac82d292d43da..d848045a83dbe8 100644 --- a/Libraries/LibDraw/PNGLoader.cpp +++ b/Libraries/LibDraw/PNGLoader.cpp @@ -138,7 +138,7 @@ RefPtr load_png(const StringView& path) MappedFile mapped_file(path); if (!mapped_file.is_valid()) return nullptr; - auto bitmap = load_png_impl((const u8*)mapped_file.pointer(), mapped_file.size()); + auto bitmap = load_png_impl((const u8*)mapped_file.data(), mapped_file.size()); if (bitmap) bitmap->set_mmap_name(String::format("GraphicsBitmap [%dx%d] - Decoded PNG: %s", bitmap->width(), bitmap->height(), canonicalized_path(path).characters())); return bitmap; @@ -271,7 +271,7 @@ template case 2: if (context.bit_depth == 8) { for (int y = 0; y < context.height; ++y) { - auto* triplets = (Triplet*)context.scanlines[y].data.pointer(); + auto* triplets = (Triplet*)context.scanlines[y].data.data(); for (int i = 0; i < context.width; ++i) { auto& pixel = (Pixel&)context.bitmap->scanline(y)[i]; pixel.r = triplets[i].r; @@ -282,7 +282,7 @@ template } } else if (context.bit_depth == 16) { for (int y = 0; y < context.height; ++y) { - auto* triplets = (Triplet16*)context.scanlines[y].data.pointer(); + auto* triplets = (Triplet16*)context.scanlines[y].data.data(); for (int i = 0; i < context.width; ++i) { auto& pixel = (Pixel&)context.bitmap->scanline(y)[i]; pixel.r = triplets[i].r & 0xFF; @@ -298,11 +298,11 @@ template case 6: if (context.bit_depth == 8) { for (int y = 0; y < context.height; ++y) { - memcpy(context.bitmap->scanline(y), context.scanlines[y].data.pointer(), context.scanlines[y].data.size()); + memcpy(context.bitmap->scanline(y), context.scanlines[y].data.data(), context.scanlines[y].data.size()); } } else if (context.bit_depth == 16) { for (int y = 0; y < context.height; ++y) { - auto* triplets = (Quad16*)context.scanlines[y].data.pointer(); + auto* triplets = (Quad16*)context.scanlines[y].data.data(); for (int i = 0; i < context.width; ++i) { auto& pixel = (Pixel&)context.bitmap->scanline(y)[i]; pixel.r = triplets[i].r & 0xFF; @@ -317,7 +317,7 @@ template break; case 3: for (int y = 0; y < context.height; ++y) { - auto* palette_index = (u8*)context.scanlines[y].data.pointer(); + auto* palette_index = (u8*)context.scanlines[y].data.data(); for (int i = 0; i < context.width; ++i) { auto& pixel = (Pixel&)context.bitmap->scanline(y)[i]; auto& color = context.palette_data.at((int)palette_index[i]); @@ -346,37 +346,37 @@ template auto filter = context.scanlines[y].filter; if (filter == 0) { if (context.has_alpha()) - unfilter_impl(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl(*context.bitmap, y, dummy_scanline.data()); else - unfilter_impl(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl(*context.bitmap, y, dummy_scanline.data()); continue; } if (filter == 1) { if (context.has_alpha()) - unfilter_impl(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl(*context.bitmap, y, dummy_scanline.data()); else - unfilter_impl(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl(*context.bitmap, y, dummy_scanline.data()); continue; } if (filter == 2) { if (context.has_alpha()) - unfilter_impl(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl(*context.bitmap, y, dummy_scanline.data()); else - unfilter_impl(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl(*context.bitmap, y, dummy_scanline.data()); continue; } if (filter == 3) { if (context.has_alpha()) - unfilter_impl(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl(*context.bitmap, y, dummy_scanline.data()); else - unfilter_impl(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl(*context.bitmap, y, dummy_scanline.data()); continue; } if (filter == 4) { if (context.has_alpha()) - unfilter_impl(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl(*context.bitmap, y, dummy_scanline.data()); else - unfilter_impl(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl(*context.bitmap, y, dummy_scanline.data()); continue; } } @@ -465,7 +465,7 @@ static bool process_IHDR(const ByteBuffer& data, PNGLoadingContext& context) { if (data.size() < (int)sizeof(PNG_IHDR)) return false; - auto& ihdr = *(const PNG_IHDR*)data.pointer(); + auto& ihdr = *(const PNG_IHDR*)data.data(); context.width = ihdr.width; context.height = ihdr.height; context.bit_depth = ihdr.bit_depth; @@ -519,13 +519,13 @@ static bool process_IHDR(const ByteBuffer& data, PNGLoadingContext& context) static bool process_IDAT(const ByteBuffer& data, PNGLoadingContext& context) { - context.compressed_data.append(data.pointer(), data.size()); + context.compressed_data.append(data.data(), data.size()); return true; } static bool process_PLTE(const ByteBuffer& data, PNGLoadingContext& context) { - context.palette_data.append((const PaletteEntry*)data.pointer(), data.size() / 3); + context.palette_data.append((const PaletteEntry*)data.data(), data.size() / 3); return true; } @@ -533,7 +533,7 @@ static bool process_tRNS(const ByteBuffer& data, PNGLoadingContext& context) { switch (context.color_type) { case 3: - context.palette_transparency_data.append(data.pointer(), data.size()); + context.palette_transparency_data.append(data.data(), data.size()); break; } return true; diff --git a/Libraries/LibPCIDB/Database.cpp b/Libraries/LibPCIDB/Database.cpp index 12aa8ea067a2dc..6568a988c20249 100644 --- a/Libraries/LibPCIDB/Database.cpp +++ b/Libraries/LibPCIDB/Database.cpp @@ -108,7 +108,7 @@ int Database::init() if (!m_file.is_valid()) return -1; - m_view = StringView((const char*)m_file.pointer(), m_file.size()); + m_view = StringView((const char*)m_file.data(), m_file.size()); ParseMode mode = ParseMode::UnknownMode; diff --git a/Servers/LookupServer/main.cpp b/Servers/LookupServer/main.cpp index 1c3dec89c54eb2..e63616412215c4 100644 --- a/Servers/LookupServer/main.cpp +++ b/Servers/LookupServer/main.cpp @@ -42,7 +42,7 @@ static void load_etc_hosts() auto line = file->read_line(1024); if (line.is_empty()) break; - auto str_line = String((const char*)line.pointer(), line.size() - 1, Chomp); + auto str_line = String((const char*)line.data(), line.size() - 1, Chomp); auto fields = str_line.split('\t'); auto sections = fields[0].split('.'); @@ -254,7 +254,7 @@ Vector lookup(const String& hostname, bool& did_timeout, const String& D dst_addr.sin_port = htons(53); rc = inet_pton(AF_INET, DNS_IP.characters(), &dst_addr.sin_addr); - int nsent = sendto(fd, buffer.pointer(), buffer.size(), 0, (const struct sockaddr*)&dst_addr, sizeof(dst_addr)); + int nsent = sendto(fd, buffer.data(), buffer.size(), 0, (const struct sockaddr*)&dst_addr, sizeof(dst_addr)); if (nsent < 0) { perror("sendto"); return {}; diff --git a/Servers/TelnetServer/Client.cpp b/Servers/TelnetServer/Client.cpp index fc0498a753518c..76d476113b6883 100644 --- a/Servers/TelnetServer/Client.cpp +++ b/Servers/TelnetServer/Client.cpp @@ -149,7 +149,7 @@ void Client::send_commands(Vector commands) for (auto& command : commands) stream << (u8)IAC << command.command << command.subcommand; stream.snip(); - m_socket->write(buffer.pointer(), buffer.size()); + m_socket->write(buffer.data(), buffer.size()); } void Client::quit() diff --git a/Shell/main.cpp b/Shell/main.cpp index 78aed03172cb82..28b4a3519fe207 100644 --- a/Shell/main.cpp +++ b/Shell/main.cpp @@ -820,7 +820,7 @@ void load_history() while (history_file->can_read_line()) { auto b = history_file->read_line(1024); // skip the newline and terminating bytes - editor.add_to_history(String(reinterpret_cast(b.pointer()), b.size() - 2)); + editor.add_to_history(String(reinterpret_cast(b.data()), b.size() - 2)); } } diff --git a/Userland/disk_benchmark.cpp b/Userland/disk_benchmark.cpp index e6f09fe441e1fb..65c9acbe3fb6d2 100644 --- a/Userland/disk_benchmark.cpp +++ b/Userland/disk_benchmark.cpp @@ -129,7 +129,7 @@ Result benchmark(const String& filename, int file_size, int block_size, ByteBuff timer.start(); int nwrote = 0; for (int j = 0; j < file_size; j += block_size) { - int n = write(fd, buffer.pointer(), block_size); + int n = write(fd, buffer.data(), block_size); if (n < 0) { perror("write"); cleanup_and_exit(); @@ -146,7 +146,7 @@ Result benchmark(const String& filename, int file_size, int block_size, ByteBuff timer.start(); int nread = 0; while (nread < file_size) { - int n = read(fd, buffer.pointer(), block_size); + int n = read(fd, buffer.data(), block_size); if (n < 0) { perror("read"); cleanup_and_exit(); diff --git a/Userland/sysctl.cpp b/Userland/sysctl.cpp index ce11eb1921be44..aaac95753735f9 100644 --- a/Userland/sysctl.cpp +++ b/Userland/sysctl.cpp @@ -27,7 +27,7 @@ static String read_var(const String& name) fprintf(stderr, "read: %s", f->error_string()); exit(1); } - return String((const char*)b.pointer(), b.size(), Chomp); + return String((const char*)b.data(), b.size(), Chomp); } static void write_var(const String& name, const String& value) diff --git a/Userland/tail.cpp b/Userland/tail.cpp index 1822d9705e91e6..ac623f46ed5d79 100644 --- a/Userland/tail.cpp +++ b/Userland/tail.cpp @@ -28,7 +28,7 @@ int tail_from_pos(CFile& file, off_t startline, bool want_follow) } } - if (write(STDOUT_FILENO, b.pointer(), b.size()) < 0) + if (write(STDOUT_FILENO, b.data(), b.size()) < 0) return 1; } @@ -57,7 +57,7 @@ off_t find_seek_pos(CFile& file, int wanted_lines) // Presumably the file got truncated? // Keep trying to read backwards... } else { - if (*ch.pointer() == '\n' && (end - pos) > 1) { + if (*ch.data() == '\n' && (end - pos) > 1) { lines++; if (lines == wanted_lines) break;