diff --git a/Outputs/CRT/Internals/Shaders/Shader.cpp b/Outputs/CRT/Internals/Shaders/Shader.cpp index ec53172e8..a82b7705d 100644 --- a/Outputs/CRT/Internals/Shaders/Shader.cpp +++ b/Outputs/CRT/Internals/Shaders/Shader.cpp @@ -239,17 +239,16 @@ void Shader::set_uniform_matrix(const std::string &name, GLint size, bool transp void Shader::set_uniform_matrix(const std::string &name, GLint size, GLsizei count, bool transpose, const GLfloat *values) { std::size_t number_of_values = static_cast(count) * static_cast(size) * static_cast(size); - GLfloat *values_copy = new GLfloat[number_of_values]; - std::memcpy(values_copy, values, sizeof(*values) * number_of_values); + std::vector values_copy(number_of_values); + std::memcpy(values_copy.data(), values, sizeof(*values) * number_of_values); enqueue_function([name, size, count, transpose, values_copy, this] { GLboolean glTranspose = transpose ? GL_TRUE : GL_FALSE; switch(size) { - case 2: glUniformMatrix2fv(location(), count, glTranspose, values_copy); break; - case 3: glUniformMatrix3fv(location(), count, glTranspose, values_copy); break; - case 4: glUniformMatrix4fv(location(), count, glTranspose, values_copy); break; + case 2: glUniformMatrix2fv(location(), count, glTranspose, values_copy.data()); break; + case 3: glUniformMatrix3fv(location(), count, glTranspose, values_copy.data()); break; + case 4: glUniformMatrix4fv(location(), count, glTranspose, values_copy.data()); break; } - delete[] values_copy; }); } diff --git a/Storage/FileHolder.cpp b/Storage/FileHolder.cpp index 38b47243e..dbba21d97 100644 --- a/Storage/FileHolder.cpp +++ b/Storage/FileHolder.cpp @@ -173,10 +173,8 @@ void FileHolder::ensure_is_at_least_length(long length) { std::fseek(file_, 0, SEEK_END); long bytes_to_write = length - ftell(file_); if(bytes_to_write > 0) { - uint8_t *empty = new uint8_t[static_cast(bytes_to_write)]; - std::memset(empty, 0, static_cast(bytes_to_write)); - std::fwrite(empty, sizeof(uint8_t), static_cast(bytes_to_write), file_); - delete[] empty; + std::vector empty(static_cast(bytes_to_write), 0); + std::fwrite(empty.data(), sizeof(uint8_t), static_cast(bytes_to_write), file_); } }