diff options
Diffstat (limited to 'ingen')
-rw-r--r-- | ingen/Atom.hpp | 14 | ||||
-rw-r--r-- | ingen/AtomForge.hpp | 13 | ||||
-rw-r--r-- | ingen/Clock.hpp | 3 | ||||
-rw-r--r-- | ingen/DataAccess.hpp | 5 | ||||
-rw-r--r-- | ingen/URI.hpp | 25 |
5 files changed, 40 insertions, 20 deletions
diff --git a/ingen/Atom.hpp b/ingen/Atom.hpp index f028088d..c4020b91 100644 --- a/ingen/Atom.hpp +++ b/ingen/Atom.hpp @@ -55,7 +55,7 @@ public: _atom.type = type; _body.ptr = nullptr; if (is_reference()) { - _body.ptr = (LV2_Atom*)malloc(sizeof(LV2_Atom) + size); + _body.ptr = static_cast<LV2_Atom*>(malloc(sizeof(LV2_Atom) + size)); memcpy(_body.ptr, &_atom, sizeof(LV2_Atom)); } if (body) { @@ -67,7 +67,9 @@ public: : _atom(copy._atom) { if (is_reference()) { - _body.ptr = (LV2_Atom*)malloc(sizeof(LV2_Atom) + _atom.size); + _body.ptr = + static_cast<LV2_Atom*>(malloc(sizeof(LV2_Atom) + _atom.size)); + memcpy(_body.ptr, copy._body.ptr, sizeof(LV2_Atom) + _atom.size); } else { _body.val = copy._body.val; @@ -81,7 +83,9 @@ public: dealloc(); _atom = other._atom; if (is_reference()) { - _body.ptr = (LV2_Atom*)malloc(sizeof(LV2_Atom) + _atom.size); + _body.ptr = + static_cast<LV2_Atom*>(malloc(sizeof(LV2_Atom) + _atom.size)); + memcpy(_body.ptr, other._body.ptr, sizeof(LV2_Atom) + _atom.size); } else { _body.val = other._body.val; @@ -133,11 +137,11 @@ public: inline bool is_valid() const { return _atom.type; } inline const void* get_body() const { - return is_reference() ? (void*)(_body.ptr + 1) : &_body.val; + return is_reference() ? static_cast<void*>(_body.ptr + 1) : &_body.val; } inline void* get_body() { - return is_reference() ? (void*)(_body.ptr + 1) : &_body.val; + return is_reference() ? static_cast<void*>(_body.ptr + 1) : &_body.val; } template <typename T> const T& get() const { diff --git a/ingen/AtomForge.hpp b/ingen/AtomForge.hpp index acb24fac..10517894 100644 --- a/ingen/AtomForge.hpp +++ b/ingen/AtomForge.hpp @@ -39,7 +39,7 @@ public: : _size{0} , _capacity{8 * sizeof(LV2_Atom)} , _sratom{sratom_new(&map)} - , _buf{(LV2_Atom*)calloc(8, sizeof(LV2_Atom))} + , _buf{static_cast<LV2_Atom*>(calloc(8, sizeof(LV2_Atom)))} { lv2_atom_forge_init(this, &map); lv2_atom_forge_set_sink(this, c_append, c_deref, this); @@ -79,11 +79,12 @@ private: // Update size and reallocate if necessary if (lv2_atom_pad_size(_size + len) > _capacity) { _capacity = lv2_atom_pad_size(_size + len); - _buf = AtomPtr{(LV2_Atom*)realloc(_buf.release(), _capacity)}; + _buf = AtomPtr{ + static_cast<LV2_Atom*>(realloc(_buf.release(), _capacity))}; } // Append new data - memcpy((uint8_t*)_buf.get() + _size, buf, len); + memcpy(reinterpret_cast<uint8_t*>(_buf.get()) + _size, buf, len); _size += len; return ref; } @@ -94,7 +95,7 @@ private: -Wcast-align. This is questionable at best, though the forge should only dereference references to aligned atoms. */ assert((ref - 1) % sizeof(LV2_Atom) == 0); - return (LV2_Atom*)(_buf.get() + (ref - 1) / sizeof(LV2_Atom)); + return static_cast<LV2_Atom*>(_buf.get() + (ref - 1) / sizeof(LV2_Atom)); // Alternatively: // return (LV2_Atom*)((uint8_t*)_buf + ref - 1); @@ -102,12 +103,12 @@ private: static LV2_Atom_Forge_Ref c_append(void* handle, const void* buf, uint32_t len) { - return ((AtomForge*)handle)->append(buf, len); + return static_cast<AtomForge*>(handle)->append(buf, len); } static LV2_Atom* c_deref(void* handle, LV2_Atom_Forge_Ref ref) { - return ((AtomForge*)handle)->deref(ref); + return static_cast<AtomForge*>(handle)->deref(ref); } size_t _size; ///< Current atom size diff --git a/ingen/Clock.hpp b/ingen/Clock.hpp index ac940fab..40204a6b 100644 --- a/ingen/Clock.hpp +++ b/ingen/Clock.hpp @@ -52,7 +52,8 @@ private: # else clock_gettime(CLOCK_MONOTONIC, &time); # endif - return (uint64_t)time.tv_sec * 1e6 + (uint64_t)time.tv_nsec / 1e3; + return static_cast<uint64_t>(time.tv_sec) * 1e6 + + static_cast<uint64_t>(time.tv_nsec) / 1e3; } #endif diff --git a/ingen/DataAccess.hpp b/ingen/DataAccess.hpp index a0c9fdf7..99847896 100644 --- a/ingen/DataAccess.hpp +++ b/ingen/DataAccess.hpp @@ -52,8 +52,9 @@ struct DataAccess : public ingen::LV2Features::Feature } const LV2_Descriptor* desc = lilv_instance_get_descriptor(inst); - LV2_Extension_Data_Feature* data = (LV2_Extension_Data_Feature*) - malloc(sizeof(LV2_Extension_Data_Feature)); + LV2_Extension_Data_Feature* data = + static_cast<LV2_Extension_Data_Feature*>( + malloc(sizeof(LV2_Extension_Data_Feature))); data->data_access = desc->extension_data; diff --git a/ingen/URI.hpp b/ingen/URI.hpp index cbbfd46a..78577d90 100644 --- a/ingen/URI.hpp +++ b/ingen/URI.hpp @@ -58,7 +58,11 @@ public: std::string string() const { return std::string(c_str(), _node.n_bytes); } size_t length() const { return _node.n_bytes; } - const char* c_str() const { return (const char*)_node.buf; } + + const char* c_str() const + { + return reinterpret_cast<const char*>(_node.buf); + } FilePath file_path() const { return scheme() == "file" ? FilePath(path()) : FilePath(); @@ -66,8 +70,15 @@ public: operator std::string() const { return string(); } - const char* begin() const { return (const char*)_node.buf; } - const char* end() const { return (const char*)_node.buf + _node.n_bytes; } + const char* begin() const + { + return reinterpret_cast<const char*>(_node.buf); + } + + const char* end() const + { + return reinterpret_cast<const char*>(_node.buf) + _node.n_bytes; + } Chunk scheme() const { return make_chunk(_uri.scheme); } Chunk authority() const { return make_chunk(_uri.authority); } @@ -75,8 +86,10 @@ public: Chunk query() const { return make_chunk(_uri.query); } Chunk fragment() const { return make_chunk(_uri.fragment); } - static bool is_valid(const char* str) { - return serd_uri_string_has_scheme((const uint8_t*)str); + static bool is_valid(const char* str) + { + return serd_uri_string_has_scheme( + reinterpret_cast<const uint8_t*>(str)); } static bool is_valid(const std::string& str) @@ -88,7 +101,7 @@ private: URI(SerdNode node, SerdURI uri); static Chunk make_chunk(const SerdChunk& chunk) { - return Chunk((const char*)chunk.buf, chunk.len); + return Chunk(reinterpret_cast<const char*>(chunk.buf), chunk.len); } SerdURI _uri; |