mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-06-08 23:13:00 +00:00
Fix multiple memory leaks and stale pooled allocations (#123)
This commit is contained in:
parent
285fab70b2
commit
544befe162
|
|
@ -8,6 +8,15 @@ GuiParticles::GuiParticles(Minecraft *mc)
|
|||
this->mc = mc;
|
||||
}
|
||||
|
||||
GuiParticles::~GuiParticles()
|
||||
{
|
||||
for (GuiParticle *gp : particles)
|
||||
{
|
||||
delete gp;
|
||||
}
|
||||
particles.clear();
|
||||
}
|
||||
|
||||
void GuiParticles::tick()
|
||||
{
|
||||
for (unsigned int i = 0; i < particles.size(); i++)
|
||||
|
|
@ -19,6 +28,7 @@ void GuiParticles::tick()
|
|||
|
||||
if (gp->removed)
|
||||
{
|
||||
delete gp;
|
||||
particles.erase(particles.begin()+i);
|
||||
i--;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ private:
|
|||
|
||||
public:
|
||||
GuiParticles(Minecraft *mc);
|
||||
~GuiParticles();
|
||||
void tick();
|
||||
void add(GuiParticle *guiParticle);
|
||||
void render(float a);
|
||||
|
|
|
|||
|
|
@ -526,9 +526,10 @@ LevelStorageSource *Minecraft::getLevelSource()
|
|||
|
||||
void Minecraft::setScreen(Screen *screen)
|
||||
{
|
||||
if (this->screen != nullptr)
|
||||
Screen *oldScreen = this->screen;
|
||||
if (oldScreen != nullptr)
|
||||
{
|
||||
this->screen->removed();
|
||||
oldScreen->removed();
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
|
|
|
|||
|
|
@ -23,6 +23,18 @@ Screen::Screen() // 4J added
|
|||
clickedButton = nullptr;
|
||||
}
|
||||
|
||||
Screen::~Screen()
|
||||
{
|
||||
delete particles;
|
||||
particles = nullptr;
|
||||
|
||||
for (Button *button : buttons)
|
||||
{
|
||||
delete button;
|
||||
}
|
||||
buttons.clear();
|
||||
}
|
||||
|
||||
void Screen::render(int xm, int ym, float a)
|
||||
{
|
||||
for (Button* button : buttons)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ public:
|
|||
GuiParticles *particles;
|
||||
|
||||
Screen(); // 4J added
|
||||
virtual ~Screen();
|
||||
virtual void render(int xm, int ym, float a);
|
||||
protected:
|
||||
virtual void keyPressed(wchar_t eventCharacter, int eventKey);
|
||||
|
|
|
|||
|
|
@ -54,10 +54,16 @@ AABB *AABB::newPermanent(double x0, double y0, double z0, double x1, double y1,
|
|||
|
||||
void AABB::clearPool()
|
||||
{
|
||||
ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
|
||||
if (tls != nullptr)
|
||||
{
|
||||
tls->poolPointer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void AABB::resetPool()
|
||||
{
|
||||
clearPool();
|
||||
}
|
||||
|
||||
AABB *AABB::newTemp(double x0, double y0, double z0, double x1, double y1, double z1)
|
||||
|
|
|
|||
|
|
@ -49,10 +49,16 @@ Vec3 *Vec3::newPermanent(double x, double y, double z)
|
|||
|
||||
void Vec3::clearPool()
|
||||
{
|
||||
ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
|
||||
if (tls != nullptr)
|
||||
{
|
||||
tls->poolPointer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Vec3::resetPool()
|
||||
{
|
||||
clearPool();
|
||||
}
|
||||
|
||||
Vec3 *Vec3::newTemp(double x, double y, double z)
|
||||
|
|
|
|||
Loading…
Reference in a new issue