diff --git a/src/common/utils/string.cpp b/src/common/utils/string.cpp index d91a210..d6b9b4f 100644 --- a/src/common/utils/string.cpp +++ b/src/common/utils/string.cpp @@ -7,7 +7,7 @@ namespace utils::string { const char* va(const char* fmt, ...) { - static thread_local va_provider<8, 256> provider; + static thread_local va_provider<8, 1024> provider; va_list ap; va_start(ap, fmt); diff --git a/src/common/utils/string.hpp b/src/common/utils/string.hpp index b05f91a..0ed5a8c 100644 --- a/src/common/utils/string.hpp +++ b/src/common/utils/string.hpp @@ -6,10 +6,10 @@ template size_t ARRAYSIZE(Type (&)[n]) { return n; } #endif namespace utils::string { -template class va_provider final { +template class va_provider final { public: - static_assert(Buffers != 0 && MinBufferSize != 0, - "Buffers and MinBufferSize mustn't be 0"); + static_assert(buffers != 0 && min_buffer_size != 0, + "buffers and min_buffer_size mustn't be 0"); va_provider() : current_buffer_(0) {} @@ -17,13 +17,13 @@ public: ++this->current_buffer_ %= ARRAYSIZE(this->string_pool_); auto entry = &this->string_pool_[this->current_buffer_]; - if (!entry->size || !entry->buffer) { + if (!entry->size_ || !entry->buffer_) { throw std::runtime_error("String pool not initialized"); } while (true) { const int res = - vsnprintf_s(entry->buffer, entry->size, _TRUNCATE, format, ap); + vsnprintf_s(entry->buffer_, entry->size_, _TRUNCATE, format, ap); if (res > 0) break; // Success if (res == 0) @@ -38,34 +38,34 @@ public: private: class entry final { public: - explicit entry(const size_t _size = MinBufferSize) - : size(_size), buffer(nullptr) { - if (this->size < MinBufferSize) - this->size = MinBufferSize; + explicit entry(const size_t size = min_buffer_size) + : size(size), buffer_(nullptr) { + if (this->size_ < min_buffer_size) + this->size_ = min_buffer_size; this->allocate(); } ~entry() { - if (this->buffer) - memory::get_allocator()->free(this->buffer); - this->size = 0; - this->buffer = nullptr; + if (this->buffer_) + memory::get_allocator()->free(this->buffer_); + this->size_ = 0; + this->buffer_ = nullptr; } void allocate() { - if (this->buffer) - memory::get_allocator()->free(this->buffer); - this->buffer = - memory::get_allocator()->allocate_array(this->size + 1); + if (this->buffer_) + memory::get_allocator()->free(this->buffer_); + this->buffer_ = + memory::get_allocator()->allocate_array(this->size_ + 1); } void double_size() { - this->size *= 2; + this->size_ *= 2; this->allocate(); } - size_t size; - char* buffer; + size_t size_; + char* buffer_; }; size_t current_buffer_;