diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-09-30 08:57:01 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-09-30 08:57:01 +0200 |
commit | 8f45a259fc9f8180b366cbaccac1af6d368e3b3a (patch) | |
tree | 5045baec395404f39728611190925f4ce39c2ae4 /Libraries | |
parent | dd696e7c75c5fb630d10d0ce37e53d88fecb58a0 (diff) | |
download | serenity-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 'Libraries')
-rw-r--r-- | Libraries/LibCore/CConfigFile.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibCore/CHttpJob.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibCore/CIODevice.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibCore/CSocket.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibDraw/Font.cpp | 4 | ||||
-rw-r--r-- | Libraries/LibDraw/GraphicsBitmap.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibDraw/PNGLoader.cpp | 40 | ||||
-rw-r--r-- | Libraries/LibPCIDB/Database.cpp | 2 |
8 files changed, 28 insertions, 28 deletions
diff --git a/Libraries/LibCore/CConfigFile.cpp b/Libraries/LibCore/CConfigFile.cpp index 7d53a27044..3b7ddfa144 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 1548ada8ae..b1605f36ae 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 2098d7ee5a..b0f6148563 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 7ac939e780..f652274b2e 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 be6bf6e462..bd51520765 100644 --- a/Libraries/LibDraw/Font.cpp +++ b/Libraries/LibDraw/Font.cpp @@ -134,7 +134,7 @@ RefPtr<Font> 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 b09996761d..7941b0a338 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 1ac82d292d..d848045a83 100644 --- a/Libraries/LibDraw/PNGLoader.cpp +++ b/Libraries/LibDraw/PNGLoader.cpp @@ -138,7 +138,7 @@ RefPtr<GraphicsBitmap> 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<bool has_alpha, u8 filter_type> 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<bool has_alpha, u8 filter_type> } } 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<bool has_alpha, u8 filter_type> 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<bool has_alpha, u8 filter_type> 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<bool has_alpha, u8 filter_type> auto filter = context.scanlines[y].filter; if (filter == 0) { if (context.has_alpha()) - unfilter_impl<true, 0>(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl<true, 0>(*context.bitmap, y, dummy_scanline.data()); else - unfilter_impl<false, 0>(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl<false, 0>(*context.bitmap, y, dummy_scanline.data()); continue; } if (filter == 1) { if (context.has_alpha()) - unfilter_impl<true, 1>(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl<true, 1>(*context.bitmap, y, dummy_scanline.data()); else - unfilter_impl<false, 1>(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl<false, 1>(*context.bitmap, y, dummy_scanline.data()); continue; } if (filter == 2) { if (context.has_alpha()) - unfilter_impl<true, 2>(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl<true, 2>(*context.bitmap, y, dummy_scanline.data()); else - unfilter_impl<false, 2>(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl<false, 2>(*context.bitmap, y, dummy_scanline.data()); continue; } if (filter == 3) { if (context.has_alpha()) - unfilter_impl<true, 3>(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl<true, 3>(*context.bitmap, y, dummy_scanline.data()); else - unfilter_impl<false, 3>(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl<false, 3>(*context.bitmap, y, dummy_scanline.data()); continue; } if (filter == 4) { if (context.has_alpha()) - unfilter_impl<true, 4>(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl<true, 4>(*context.bitmap, y, dummy_scanline.data()); else - unfilter_impl<false, 4>(*context.bitmap, y, dummy_scanline.pointer()); + unfilter_impl<false, 4>(*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 12aa8ea067..6568a988c2 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; |