From: Mikko Rasa Date: Tue, 2 Nov 2021 14:44:13 +0000 (+0200) Subject: Use size_t for memory buffer sizes X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=8a4fca97e2bf3a3934399123e8f7cbd591912f83;p=libs%2Fdatafile.git Use size_t for memory buffer sizes --- diff --git a/source/builtinsource.cpp b/source/builtinsource.cpp index 5d19fbe..5645467 100644 --- a/source/builtinsource.cpp +++ b/source/builtinsource.cpp @@ -8,7 +8,7 @@ using namespace std; namespace Msp { namespace DataFile { -void BuiltinSource::add_object(const string &name, const char *content, unsigned size) +void BuiltinSource::add_object(const string &name, const char *content, size_t size) { objects[name] = Object(content, size); } @@ -53,7 +53,7 @@ IO::Seekable *BuiltinSource::open(const string &name) const } -BuiltinSource::Object::Object(const char *d, unsigned s): +BuiltinSource::Object::Object(const char *d, size_t s): data(d), size(s) { } diff --git a/source/builtinsource.h b/source/builtinsource.h index 8278508..e81b37f 100644 --- a/source/builtinsource.h +++ b/source/builtinsource.h @@ -12,16 +12,16 @@ private: struct Object { const char *data = nullptr; - unsigned size = 0; + std::size_t size = 0; Object() = default; - Object(const char *, unsigned); + Object(const char *, std::size_t); }; std::map objects; public: - void add_object(const std::string &, const char *, unsigned); + void add_object(const std::string &, const char *, std::size_t); void add_object(const std::string &, const char *); bool is_loadable(const CollectionItemTypeBase &, const std::string &) const override; diff --git a/source/output.cpp b/source/output.cpp index f467337..46d270a 100644 --- a/source/output.cpp +++ b/source/output.cpp @@ -21,12 +21,12 @@ void Output::set_compressed() out = compressed; } -unsigned Output::put(char c) +size_t Output::put(char c) { return out->put(c); } -unsigned Output::write(const string &s) +size_t Output::write(const string &s) { return out->write(s); } diff --git a/source/output.h b/source/output.h index 931c01f..4a4bc81 100644 --- a/source/output.h +++ b/source/output.h @@ -19,8 +19,8 @@ public: void set_compressed(); - unsigned put(char); - unsigned write(const std::string &); + std::size_t put(char); + std::size_t write(const std::string &); }; } // namespace DataFile diff --git a/source/statement.h b/source/statement.h index f20bf11..a580f37 100644 --- a/source/statement.h +++ b/source/statement.h @@ -55,8 +55,8 @@ struct StatementKey struct StatementInfo { StatementKey key; - unsigned args_size = 0; - std::vector arg_offsets; + std::size_t args_size = 0; + std::vector arg_offsets; StatementInfo() = default; StatementInfo(const std::string &, const std::string &);