From d98b7b6087c1a5d0ed75237119de853ab73527c3 Mon Sep 17 00:00:00 2001 From: Lukas Rusak Date: Thu, 20 Apr 2023 13:22:22 -0700 Subject: [PATCH] CScreensaverPyro: use std::vector for m_projectiles Signed-off-by: Lukas Rusak --- src/Pyro.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Pyro.cpp b/src/Pyro.cpp index b1657c1..4239178 100644 --- a/src/Pyro.cpp +++ b/src/Pyro.cpp @@ -17,6 +17,9 @@ #endif #include "Pyro.h" + +#include + #include #include #include @@ -129,7 +132,7 @@ class ATTR_DLL_LOCAL CScreensaverPyro int m_iWidth; int m_iHeight; - struct projectile *m_projectiles; + std::vector m_projectiles; struct projectile *m_free_projectiles; int m_how_many; @@ -171,9 +174,10 @@ CScreensaverPyro::CScreensaverPyro() bool CScreensaverPyro::Start() { m_free_projectiles = nullptr; - m_projectiles = static_cast(calloc(m_how_many, sizeof (struct projectile))); - for (int i = 0; i < m_how_many; i++) - free_projectile(&m_projectiles[i]); + m_projectiles.resize(m_how_many); + + for (auto& projectile : m_projectiles) + free_projectile(&projectile); #ifndef WIN32 std::string fraqShader = kodi::addon::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/frag.glsl"); @@ -265,7 +269,6 @@ void CScreensaverPyro::Render() // any resources we have created. void CScreensaverPyro::Stop() { - free(m_projectiles); #ifndef WIN32 glDeleteBuffers(1, &m_vertexVBO); m_vertexVBO = 0;