From 5ef313004bf754dc5c5e3dd795c4e3f4de77e672 Mon Sep 17 00:00:00 2001 From: lganzzzo Date: Sat, 23 Nov 2019 04:11:48 +0200 Subject: [PATCH] Refactor. More consistent integer types. --- src/oatpp/algorithm/CRC.cpp | 4 +-- src/oatpp/algorithm/CRC.hpp | 2 +- src/oatpp/core/base/Environment.hpp | 8 ++++- src/oatpp/core/base/memory/MemoryPool.cpp | 2 +- src/oatpp/core/data/buffer/FIFOBuffer.cpp | 14 ++++---- src/oatpp/core/data/buffer/FIFOBuffer.hpp | 14 ++++---- src/oatpp/core/data/buffer/IOBuffer.cpp | 2 +- src/oatpp/core/data/buffer/IOBuffer.hpp | 4 +-- src/oatpp/core/data/stream/BufferStream.cpp | 30 ++++++++--------- src/oatpp/core/data/stream/BufferStream.hpp | 32 +++++++++---------- src/oatpp/core/data/stream/ChunkedBuffer.cpp | 6 ++-- src/oatpp/core/data/stream/ChunkedBuffer.hpp | 14 ++++---- .../core/data/stream/StreamBufferedProxy.hpp | 4 --- src/oatpp/core/utils/Random.cpp | 4 +-- src/oatpp/core/utils/Random.hpp | 2 +- src/oatpp/web/mime/multipart/Part.cpp | 6 ++-- src/oatpp/web/mime/multipart/Part.hpp | 8 ++--- src/oatpp/web/protocol/http/Http.cpp | 12 +++---- test/oatpp/network/virtual_/PipeTest.cpp | 4 +-- .../web/mime/multipart/StatefulParserTest.cpp | 4 +-- 20 files changed, 88 insertions(+), 88 deletions(-) diff --git a/src/oatpp/algorithm/CRC.cpp b/src/oatpp/algorithm/CRC.cpp index 287deaf1..ea448793 100644 --- a/src/oatpp/algorithm/CRC.cpp +++ b/src/oatpp/algorithm/CRC.cpp @@ -62,12 +62,12 @@ p_word32 CRC32::generateTable(v_word32 poly) { } -v_word32 CRC32::calc(const void *buffer, v_int32 size, v_word32 crc, v_word32 initValue, v_word32 xorOut, p_word32 table) { +v_word32 CRC32::calc(const void *buffer, v_buff_size size, v_word32 crc, v_word32 initValue, v_word32 xorOut, p_word32 table) { p_word8 data = (p_word8) buffer; crc = crc ^ initValue; - for(v_int32 i = 0; i < size; i++) { + for(v_buff_size i = 0; i < size; i++) { crc = table[(crc & 0xFF) ^ data[i]] ^ (crc >> 8); } diff --git a/src/oatpp/algorithm/CRC.hpp b/src/oatpp/algorithm/CRC.hpp index 86635a38..805a1a06 100644 --- a/src/oatpp/algorithm/CRC.hpp +++ b/src/oatpp/algorithm/CRC.hpp @@ -60,7 +60,7 @@ public: * @param table * @return - CRC32 value (v_word32) */ - static v_word32 calc(const void *buffer, v_int32 size, v_word32 crc = 0, v_word32 initValue = 0xFFFFFFFF, v_word32 xorOut = 0xFFFFFFFF, p_word32 table = TABLE_04C11DB7); + static v_word32 calc(const void *buffer, v_buff_size size, v_word32 crc = 0, v_word32 initValue = 0xFFFFFFFF, v_word32 xorOut = 0xFFFFFFFF, p_word32 table = TABLE_04C11DB7); }; diff --git a/src/oatpp/core/base/Environment.hpp b/src/oatpp/core/base/Environment.hpp index 4fae2db5..353b47e8 100644 --- a/src/oatpp/core/base/Environment.hpp +++ b/src/oatpp/core/base/Environment.hpp @@ -70,9 +70,15 @@ typedef v_float32* p_float32; typedef std::atomic_int_fast64_t v_atomicCounter; typedef v_int64 v_counter; +/** + * This type is the integer type capable of storing a pointer. Thus is capable of storing size of allocated memory.
+ * Use this type to define a size for the buffer. + */ typedef intptr_t v_buff_size; -namespace oatpp { namespace base{ +typedef v_buff_size* p_buff_size; + +namespace oatpp { namespace base { /** * Interface for system-wide Logger.
diff --git a/src/oatpp/core/base/memory/MemoryPool.cpp b/src/oatpp/core/base/memory/MemoryPool.cpp index 9efa4ad7..551c4770 100644 --- a/src/oatpp/core/base/memory/MemoryPool.cpp +++ b/src/oatpp/core/base/memory/MemoryPool.cpp @@ -143,7 +143,7 @@ ThreadDistributedMemoryPool::ThreadDistributedMemoryPool(const std::string& name , m_deleted(false) { for(v_int64 i = 0; i < m_shardsCount; i++){ - m_shards[i] = new MemoryPool(name + "_" + oatpp::utils::conversion::int32ToStdStr(i), entrySize, chunkSize); + m_shards[i] = new MemoryPool(name + "_" + oatpp::utils::conversion::int64ToStdStr(i), entrySize, chunkSize); } } #else diff --git a/src/oatpp/core/data/buffer/FIFOBuffer.cpp b/src/oatpp/core/data/buffer/FIFOBuffer.cpp index a6870ecc..c8b13e8e 100644 --- a/src/oatpp/core/data/buffer/FIFOBuffer.cpp +++ b/src/oatpp/core/data/buffer/FIFOBuffer.cpp @@ -27,8 +27,8 @@ namespace oatpp { namespace data{ namespace buffer { -FIFOBuffer::FIFOBuffer(void* buffer, v_io_size bufferSize, - data::v_io_size readPosition, data::v_io_size writePosition, +FIFOBuffer::FIFOBuffer(void* buffer, v_buff_size bufferSize, + v_buff_size readPosition, v_buff_size writePosition, bool canRead) : m_buffer((p_char8)buffer) , m_bufferSize(bufferSize) @@ -37,7 +37,7 @@ FIFOBuffer::FIFOBuffer(void* buffer, v_io_size bufferSize, , m_canRead(canRead) {} -void FIFOBuffer::setBufferPosition(data::v_io_size readPosition, data::v_io_size writePosition, bool canRead) { +void FIFOBuffer::setBufferPosition(v_buff_size readPosition, v_buff_size writePosition, bool canRead) { m_readPosition = readPosition; m_writePosition = writePosition; m_canRead = canRead; @@ -63,7 +63,7 @@ data::v_io_size FIFOBuffer::availableToWrite() const { return (m_bufferSize - m_writePosition + m_readPosition); } -data::v_io_size FIFOBuffer::getBufferSize() const { +v_buff_size FIFOBuffer::getBufferSize() const { return m_bufferSize; } @@ -435,13 +435,13 @@ async::CoroutineStarter FIFOBuffer::flushToStreamAsync(const std::shared_ptr lock(m_lock); m_fifo.setBufferPosition(readPosition, writePosition, canRead); } diff --git a/src/oatpp/core/data/buffer/FIFOBuffer.hpp b/src/oatpp/core/data/buffer/FIFOBuffer.hpp index 9bdf1324..d51821af 100644 --- a/src/oatpp/core/data/buffer/FIFOBuffer.hpp +++ b/src/oatpp/core/data/buffer/FIFOBuffer.hpp @@ -54,8 +54,8 @@ public: * @param canRead - flag to resolve ambiguity when readPosition == writePosition. If(readPosition == writePosition && canRead) then * &l:FIFOBuffer::availableToRead (); returns buffer size, and &l:FIFOBuffer::availableToWrite (); returns 0. */ - FIFOBuffer(void* buffer, v_io_size bufferSize, - data::v_io_size readPosition = 0, data::v_io_size writePosition = 0, + FIFOBuffer(void* buffer, v_buff_size bufferSize, + v_buff_size readPosition = 0, v_buff_size writePosition = 0, bool canRead = false); /** @@ -65,7 +65,7 @@ public: * @param canRead - flag to resolve ambiguity when readPosition == writePosition. If(readPosition == writePosition && canRead) then * &l:FIFOBuffer::availableToRead (); returns buffer size, and &l:FIFOBuffer::availableToWrite (); returns 0. */ - void setBufferPosition(data::v_io_size readPosition, data::v_io_size writePosition, bool canRead); + void setBufferPosition(v_buff_size readPosition, v_buff_size writePosition, bool canRead); /** * Amount of bytes currently available to read from buffer. @@ -83,7 +83,7 @@ public: * Get FIFOBuffer size. * @return - FIFOBuffer size. */ - data::v_io_size getBufferSize() const; + v_buff_size getBufferSize() const; /** * read up to count bytes from the buffer to data @@ -167,8 +167,8 @@ public: * @param canRead - flag to resolve ambiguity when readPosition == writePosition. If(readPosition == writePosition && canRead) then * &l:SynchronizedFIFOBuffer::availableToRead (); returns buffer size, and &l:SynchronizedFIFOBuffer::availableToWrite (); returns 0. */ - SynchronizedFIFOBuffer(void* buffer, v_io_size bufferSize, - data::v_io_size readPosition = 0, data::v_io_size writePosition = 0, + SynchronizedFIFOBuffer(void* buffer, v_buff_size bufferSize, + v_buff_size readPosition = 0, v_buff_size writePosition = 0, bool canRead = false); /** @@ -178,7 +178,7 @@ public: * @param canRead - flag to resolve ambiguity when readPosition == writePosition. If(readPosition == writePosition && canRead) then * &l:SynchronizedFIFOBuffer::availableToRead (); returns buffer size, and &l:SynchronizedFIFOBuffer::availableToWrite (); returns 0. */ - void setBufferPosition(data::v_io_size readPosition, data::v_io_size writePosition, bool canRead); + void setBufferPosition(v_buff_size readPosition, v_buff_size writePosition, bool canRead); /** * Amount of bytes currently available to read from buffer. diff --git a/src/oatpp/core/data/buffer/IOBuffer.cpp b/src/oatpp/core/data/buffer/IOBuffer.cpp index 802aaa12..95bb4d9f 100644 --- a/src/oatpp/core/data/buffer/IOBuffer.cpp +++ b/src/oatpp/core/data/buffer/IOBuffer.cpp @@ -42,7 +42,7 @@ void* IOBuffer::getData(){ return m_entry; } -v_int32 IOBuffer::getSize(){ +v_buff_size IOBuffer::getSize(){ return BUFFER_SIZE; } diff --git a/src/oatpp/core/data/buffer/IOBuffer.hpp b/src/oatpp/core/data/buffer/IOBuffer.hpp index e56217e7..834c8130 100644 --- a/src/oatpp/core/data/buffer/IOBuffer.hpp +++ b/src/oatpp/core/data/buffer/IOBuffer.hpp @@ -42,7 +42,7 @@ public: /** * Buffer size constant. */ - static constexpr v_int32 BUFFER_SIZE = 4096; + static constexpr v_buff_size BUFFER_SIZE = 4096; private: static oatpp::base::memory::ThreadDistributedMemoryPool& getBufferPool(){ static oatpp::base::memory::ThreadDistributedMemoryPool pool("IOBuffer_Buffer_Pool", BUFFER_SIZE, 16); @@ -78,7 +78,7 @@ public: * Get buffer size. * @return - should always return &l:IOBuffer::BUFFER_SIZE;. */ - v_int32 getSize(); + v_buff_size getSize(); }; diff --git a/src/oatpp/core/data/stream/BufferStream.cpp b/src/oatpp/core/data/stream/BufferStream.cpp index 230b5560..1d9e39d2 100644 --- a/src/oatpp/core/data/stream/BufferStream.cpp +++ b/src/oatpp/core/data/stream/BufferStream.cpp @@ -29,7 +29,7 @@ namespace oatpp { namespace data{ namespace stream { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // BufferOutputStream -BufferOutputStream::BufferOutputStream(v_io_size initialCapacity, v_io_size growBytes) +BufferOutputStream::BufferOutputStream(v_buff_size initialCapacity, v_buff_size growBytes) : m_data(new v_char8[initialCapacity]) , m_capacity(initialCapacity) , m_position(0) @@ -60,7 +60,7 @@ IOMode BufferOutputStream::getOutputStreamIOMode() { return m_ioMode; } -void BufferOutputStream::reserveBytesUpfront(v_io_size count) { +void BufferOutputStream::reserveBytesUpfront(v_buff_size count) { if(m_position + count > m_capacity) { @@ -68,14 +68,14 @@ void BufferOutputStream::reserveBytesUpfront(v_io_size count) { throw std::runtime_error("[oatpp::data::stream::BufferOutputStream::reserveBytesUpfront()]: Error. Buffer was not allowed to grow."); } - data::v_io_size extraNeeded = m_position + count - m_capacity; - data::v_io_size extraChunks = extraNeeded / m_growBytes; + v_buff_size extraNeeded = m_position + count - m_capacity; + v_buff_size extraChunks = extraNeeded / m_growBytes; if(extraChunks * m_growBytes < extraNeeded) { extraChunks ++; } - data::v_io_size newCapacity = m_capacity + extraChunks * m_growBytes; + v_buff_size newCapacity = m_capacity + extraChunks * m_growBytes; p_char8 newData = new v_char8[newCapacity]; std::memcpy(newData, m_data, m_position); @@ -92,17 +92,17 @@ p_char8 BufferOutputStream::getData() { } -v_io_size BufferOutputStream::getCapacity() { +v_buff_size BufferOutputStream::getCapacity() { return m_capacity; } -v_io_size BufferOutputStream::getCurrentPosition() { +v_buff_size BufferOutputStream::getCurrentPosition() { return m_position; } -void BufferOutputStream::setCurrentPosition(v_io_size position) { +void BufferOutputStream::setCurrentPosition(v_buff_size position) { m_position = position; } @@ -110,7 +110,7 @@ oatpp::String BufferOutputStream::toString() { return oatpp::String((const char*)m_data, m_position, true); } -oatpp::String BufferOutputStream::getSubstring(data::v_io_size pos, v_buff_size count) { +oatpp::String BufferOutputStream::getSubstring(v_buff_size pos, v_buff_size count) { if(pos + count <= m_position) { return oatpp::String((const char *) (m_data + pos), count, true); } else { @@ -155,7 +155,7 @@ oatpp::async::CoroutineStarter BufferOutputStream::flushToStreamAsync(const std: //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // BufferInputStream -BufferInputStream::BufferInputStream(const std::shared_ptr& memoryHandle, p_char8 data, v_io_size size) +BufferInputStream::BufferInputStream(const std::shared_ptr& memoryHandle, p_char8 data, v_buff_size size) : m_memoryHandle(memoryHandle) , m_data(data) , m_size(size) @@ -167,7 +167,7 @@ BufferInputStream::BufferInputStream(const oatpp::String& data) : BufferInputStream(data.getPtr(), data->getData(), data->getSize()) {} -void BufferInputStream::reset(const std::shared_ptr& memoryHandle, p_char8 data, v_io_size size) { +void BufferInputStream::reset(const std::shared_ptr& memoryHandle, p_char8 data, v_buff_size size) { m_memoryHandle = memoryHandle; m_data = data; m_size = size; @@ -182,7 +182,7 @@ void BufferInputStream::reset() { } data::v_io_size BufferInputStream::read(void *data, v_buff_size count) { - data::v_io_size desiredAmount = count; + v_buff_size desiredAmount = count; if(desiredAmount > m_size - m_position) { desiredAmount = m_size - m_position; } @@ -223,15 +223,15 @@ p_char8 BufferInputStream::getData() { return m_data; } -v_io_size BufferInputStream::getDataSize() { +v_buff_size BufferInputStream::getDataSize() { return m_size; } -v_io_size BufferInputStream::getCurrentPosition() { +v_buff_size BufferInputStream::getCurrentPosition() { return m_position; } -void BufferInputStream::setCurrentPosition(v_io_size position) { +void BufferInputStream::setCurrentPosition(v_buff_size position) { m_position = position; } diff --git a/src/oatpp/core/data/stream/BufferStream.hpp b/src/oatpp/core/data/stream/BufferStream.hpp index d03ec75e..e337f27f 100644 --- a/src/oatpp/core/data/stream/BufferStream.hpp +++ b/src/oatpp/core/data/stream/BufferStream.hpp @@ -35,9 +35,9 @@ namespace oatpp { namespace data{ namespace stream { class BufferOutputStream : public ConsistentOutputStream { private: p_char8 m_data; - v_io_size m_capacity; - v_io_size m_position; - v_io_size m_growBytes; + v_buff_size m_capacity; + v_buff_size m_position; + v_buff_size m_growBytes; IOMode m_ioMode; public: @@ -45,7 +45,7 @@ public: * Constructor. * @param growBytes */ - BufferOutputStream(v_io_size initialCapacity = 2048, v_io_size growBytes = 2048); + BufferOutputStream(v_buff_size initialCapacity = 2048, v_buff_size growBytes = 2048); /** * Virtual destructor. @@ -75,7 +75,7 @@ public: /** * Reserve bytes for future writes. */ - void reserveBytesUpfront(v_io_size count); + void reserveBytesUpfront(v_buff_size count); /** * Get pointer to data. @@ -88,19 +88,19 @@ public: * Capacity may change. * @return */ - v_io_size getCapacity(); + v_buff_size getCapacity(); /** * Get current data write position. * @return - current data write position. */ - v_io_size getCurrentPosition(); + v_buff_size getCurrentPosition(); /** * Set current data write position. * @param position - data write position. */ - void setCurrentPosition(v_io_size position); + void setCurrentPosition(v_buff_size position); /** * Copy data to &id:oatpp::String;. @@ -114,7 +114,7 @@ public: * @param count - size of bytes to write to substring. * @return - &id:oatpp::String; */ - oatpp::String getSubstring(data::v_io_size pos, v_buff_size count); + oatpp::String getSubstring(v_buff_size pos, v_buff_size count); /** * Write all bytes from buffer to stream. @@ -140,8 +140,8 @@ class BufferInputStream : public InputStream { private: std::shared_ptr m_memoryHandle; p_char8 m_data; - v_io_size m_size; - v_io_size m_position; + v_buff_size m_size; + v_buff_size m_position; IOMode m_ioMode; public: @@ -151,7 +151,7 @@ public: * @param data - pointer to buffer data. * @param size - size of the buffer. */ - BufferInputStream(const std::shared_ptr& memoryHandle, p_char8 data, v_io_size size); + BufferInputStream(const std::shared_ptr& memoryHandle, p_char8 data, v_buff_size size); /** * Constructor. @@ -165,7 +165,7 @@ public: * @param data - pointer to buffer data. * @param size - size of the buffer. */ - void reset(const std::shared_ptr& memoryHandle, p_char8 data, v_io_size size); + void reset(const std::shared_ptr& memoryHandle, p_char8 data, v_buff_size size); /** @@ -219,19 +219,19 @@ public: * Get data size. * @return - data size. */ - v_io_size getDataSize(); + v_buff_size getDataSize(); /** * Get current data read position. * @return - current data read position. */ - v_io_size getCurrentPosition(); + v_buff_size getCurrentPosition(); /** * Set current data read position. * @param position - data read position. */ - void setCurrentPosition(v_io_size position); + void setCurrentPosition(v_buff_size position); }; diff --git a/src/oatpp/core/data/stream/ChunkedBuffer.cpp b/src/oatpp/core/data/stream/ChunkedBuffer.cpp index 25a3577b..88ec16ff 100644 --- a/src/oatpp/core/data/stream/ChunkedBuffer.cpp +++ b/src/oatpp/core/data/stream/ChunkedBuffer.cpp @@ -30,10 +30,10 @@ const char* ChunkedBuffer::ERROR_ASYNC_FAILED_TO_WRITE_ALL_DATA = "ERROR_ASYNC_F const char* const ChunkedBuffer::CHUNK_POOL_NAME = "ChunkedBuffer_Chunk_Pool"; -const data::v_io_size ChunkedBuffer::CHUNK_ENTRY_SIZE_INDEX_SHIFT = 11; -const data::v_io_size ChunkedBuffer::CHUNK_ENTRY_SIZE = +const v_buff_size ChunkedBuffer::CHUNK_ENTRY_SIZE_INDEX_SHIFT = 11; +const v_buff_size ChunkedBuffer::CHUNK_ENTRY_SIZE = (1 << ChunkedBuffer::CHUNK_ENTRY_SIZE_INDEX_SHIFT); -const data::v_io_size ChunkedBuffer::CHUNK_CHUNK_SIZE = 32; +const v_buff_size ChunkedBuffer::CHUNK_CHUNK_SIZE = 32; ChunkedBuffer::ChunkedBuffer() : m_size(0) diff --git a/src/oatpp/core/data/stream/ChunkedBuffer.hpp b/src/oatpp/core/data/stream/ChunkedBuffer.hpp index abf7b206..34b19932 100644 --- a/src/oatpp/core/data/stream/ChunkedBuffer.hpp +++ b/src/oatpp/core/data/stream/ChunkedBuffer.hpp @@ -45,14 +45,12 @@ public: static const char* const CHUNK_POOL_NAME; - static const data::v_io_size CHUNK_ENTRY_SIZE_INDEX_SHIFT; - static const data::v_io_size CHUNK_ENTRY_SIZE; - static const data::v_io_size CHUNK_CHUNK_SIZE; + static const v_buff_size CHUNK_ENTRY_SIZE_INDEX_SHIFT; + static const v_buff_size CHUNK_ENTRY_SIZE; + static const v_buff_size CHUNK_CHUNK_SIZE; static oatpp::base::memory::ThreadDistributedMemoryPool& getSegemntPool(){ - static oatpp::base::memory::ThreadDistributedMemoryPool pool(CHUNK_POOL_NAME, - (v_int32) CHUNK_ENTRY_SIZE, - (v_int32) CHUNK_CHUNK_SIZE); + static oatpp::base::memory::ThreadDistributedMemoryPool pool(CHUNK_POOL_NAME, CHUNK_ENTRY_SIZE, CHUNK_CHUNK_SIZE); return pool; } @@ -84,7 +82,7 @@ public: SHARED_OBJECT_POOL(Shared_ChunkedBuffer_Chunk_Pool, Chunk, 32) public: - Chunk(void* pData, data::v_io_size pSize) + Chunk(void* pData, v_buff_size pSize) : data(pData) , size(pSize) {} @@ -94,7 +92,7 @@ public: } const void* data; - const data::v_io_size size; + const v_buff_size size; }; diff --git a/src/oatpp/core/data/stream/StreamBufferedProxy.hpp b/src/oatpp/core/data/stream/StreamBufferedProxy.hpp index 8a4a7e3e..23632cb5 100644 --- a/src/oatpp/core/data/stream/StreamBufferedProxy.hpp +++ b/src/oatpp/core/data/stream/StreamBufferedProxy.hpp @@ -36,8 +36,6 @@ class OutputStreamBufferedProxy : public oatpp::base::Countable, public OutputSt public: OBJECT_POOL(OutputStreamBufferedProxy_Pool, OutputStreamBufferedProxy, 32) SHARED_OBJECT_POOL(Shared_OutputStreamBufferedProxy_Pool, OutputStreamBufferedProxy, 32) -public: - typedef v_int32 v_bufferSize; private: std::shared_ptr m_outputStream; oatpp::data::share::MemoryLabel m_memoryLabel; @@ -84,8 +82,6 @@ class InputStreamBufferedProxy : public oatpp::base::Countable, public InputStre public: OBJECT_POOL(InputStreamBufferedProxy_Pool, InputStreamBufferedProxy, 32) SHARED_OBJECT_POOL(Shared_InputStreamBufferedProxy_Pool, InputStreamBufferedProxy, 32) -public: - typedef v_int32 v_bufferSize; protected: std::shared_ptr m_inputStream; oatpp::data::share::MemoryLabel m_memoryLabel; diff --git a/src/oatpp/core/utils/Random.cpp b/src/oatpp/core/utils/Random.cpp index b5b5c2fc..e1739dfc 100644 --- a/src/oatpp/core/utils/Random.cpp +++ b/src/oatpp/core/utils/Random.cpp @@ -33,7 +33,7 @@ namespace oatpp { namespace utils { namespace random { oatpp::concurrency::SpinLock Random::RANDOM_LOCK; #endif -void Random::randomBytes(p_char8 buffer, v_int32 bufferSize) { +void Random::randomBytes(p_char8 buffer, v_buff_size bufferSize) { #if defined(OATPP_COMPAT_BUILD_NO_THREAD_LOCAL) std::lock_guard randomLock(RANDOM_LOCK); @@ -41,7 +41,7 @@ void Random::randomBytes(p_char8 buffer, v_int32 bufferSize) { std::uniform_int_distribution distribution(0, 255); - for(v_int32 i = 0; i < bufferSize; i ++) { + for(v_buff_size i = 0; i < bufferSize; i ++) { buffer[i] = (v_char8) distribution(RANDOM_GENERATOR); } diff --git a/src/oatpp/core/utils/Random.hpp b/src/oatpp/core/utils/Random.hpp index d6109ef2..7c318dc2 100644 --- a/src/oatpp/core/utils/Random.hpp +++ b/src/oatpp/core/utils/Random.hpp @@ -49,7 +49,7 @@ public: * @param buffer - pointer to buffer. * @param bufferSize - size of the buffer. */ - static void randomBytes(p_char8 buffer, v_int32 bufferSize); + static void randomBytes(p_char8 buffer, v_buff_size bufferSize); }; diff --git a/src/oatpp/web/mime/multipart/Part.cpp b/src/oatpp/web/mime/multipart/Part.cpp index e5e35387..1fd8aad3 100644 --- a/src/oatpp/web/mime/multipart/Part.cpp +++ b/src/oatpp/web/mime/multipart/Part.cpp @@ -34,7 +34,7 @@ namespace oatpp { namespace web { namespace mime { namespace multipart { Part::Part(const Headers &headers, const std::shared_ptr &inputStream, const oatpp::String inMemoryData, - data::v_io_size knownSize) + v_int64 knownSize) : m_headers(headers) , m_inputStream(inputStream) , m_inMemoryData(inMemoryData) @@ -59,7 +59,7 @@ Part::Part(const Headers& headers) : Part(headers, nullptr, nullptr, -1) {} void Part::setDataInfo(const std::shared_ptr& inputStream, const oatpp::String inMemoryData, - data::v_io_size knownSize) + v_int64 knownSize) { m_inputStream = inputStream; m_inMemoryData = inMemoryData; @@ -106,7 +106,7 @@ oatpp::String Part::getInMemoryData() const { return m_inMemoryData; } -data::v_io_size Part::getKnownSize() const { +v_int64 Part::getKnownSize() const { return m_knownSize; } diff --git a/src/oatpp/web/mime/multipart/Part.hpp b/src/oatpp/web/mime/multipart/Part.hpp index 27948d71..1e43cb2d 100644 --- a/src/oatpp/web/mime/multipart/Part.hpp +++ b/src/oatpp/web/mime/multipart/Part.hpp @@ -46,7 +46,7 @@ private: Headers m_headers; std::shared_ptr m_inputStream; oatpp::String m_inMemoryData; - data::v_io_size m_knownSize; + v_int64 m_knownSize; private: const char* m_tagName; std::shared_ptr m_tagObject; @@ -62,7 +62,7 @@ public: Part(const Headers& headers, const std::shared_ptr& inputStream, const oatpp::String inMemoryData, - data::v_io_size knownSize); + v_int64 knownSize); /** * Constructor. @@ -78,7 +78,7 @@ public: */ void setDataInfo(const std::shared_ptr& inputStream, const oatpp::String inMemoryData, - data::v_io_size knownSize); + v_int64 knownSize); /** * Same as `setDataInfo(inputStream, nullptr, -1);.` @@ -144,7 +144,7 @@ public: * Return known size of the part data. * @return - known size of the part data. `-1` - if size is unknown. */ - data::v_io_size getKnownSize() const; + v_int64 getKnownSize() const; /** * Tag-object - object used to associate some data with the Part.
diff --git a/src/oatpp/web/protocol/http/Http.cpp b/src/oatpp/web/protocol/http/Http.cpp index 241a1f67..755cb9e0 100644 --- a/src/oatpp/web/protocol/http/Http.cpp +++ b/src/oatpp/web/protocol/http/Http.cpp @@ -164,9 +164,9 @@ Range Range::parse(oatpp::parser::Caret& caret) { auto endLabel = caret.putLabel(); caret.findRN(); endLabel.end(); - - oatpp::data::v_io_size start = oatpp::utils::conversion::strToInt64((const char*) startLabel.getData()); - oatpp::data::v_io_size end = oatpp::utils::conversion::strToInt64((const char*) endLabel.getData()); + + auto start = oatpp::utils::conversion::strToInt64((const char*) startLabel.getData()); + auto end = oatpp::utils::conversion::strToInt64((const char*) endLabel.getData()); return Range(unitsLabel.toString(true), start, end); } @@ -225,9 +225,9 @@ ContentRange ContentRange::parse(oatpp::parser::Caret& caret) { caret.findRN(); sizeLabel.end(); - oatpp::data::v_io_size start = oatpp::utils::conversion::strToInt64((const char*) startLabel.getData()); - oatpp::data::v_io_size end = oatpp::utils::conversion::strToInt64((const char*) endLabel.getData()); - oatpp::data::v_io_size size = 0; + v_int64 start = oatpp::utils::conversion::strToInt64((const char*) startLabel.getData()); + v_int64 end = oatpp::utils::conversion::strToInt64((const char*) endLabel.getData()); + v_int64 size = 0; bool isSizeKnown = false; if(sizeLabel.getData()[0] != '*') { isSizeKnown = true; diff --git a/test/oatpp/network/virtual_/PipeTest.cpp b/test/oatpp/network/virtual_/PipeTest.cpp index d37a214e..fa9887cf 100644 --- a/test/oatpp/network/virtual_/PipeTest.cpp +++ b/test/oatpp/network/virtual_/PipeTest.cpp @@ -46,8 +46,8 @@ namespace { private: std::shared_ptr m_pipe; v_int64 m_chunksToTransfer; - data::v_io_size m_position = 0; - data::v_io_size m_transferedBytes = 0; + v_buff_size m_position = 0; + v_buff_size m_transferedBytes = 0; public: WriterTask(const std::shared_ptr& pipe, v_int64 chunksToTransfer) diff --git a/test/oatpp/web/mime/multipart/StatefulParserTest.cpp b/test/oatpp/web/mime/multipart/StatefulParserTest.cpp index 1db2164e..5a3cbc68 100644 --- a/test/oatpp/web/mime/multipart/StatefulParserTest.cpp +++ b/test/oatpp/web/mime/multipart/StatefulParserTest.cpp @@ -65,9 +65,9 @@ namespace { oatpp::data::stream::BufferInputStream stream(text.getPtr(), text->getData(), text->getSize()); std::unique_ptr buffer(new v_char8[step]); - v_int64 size; + data::v_io_size size; while((size = stream.read(buffer.get(), step)) != 0) { - parser.parseNext(buffer.get(), size); + parser.parseNext(buffer.get(), (v_buff_size) size); } OATPP_ASSERT(parser.finished());