Clearing up some memory to prevent stupid issues

Preparing for some optimisations. (absolutely need to reduce the ammount of allocations done.)
This commit is contained in:
Godzil
2020-03-02 08:24:09 +00:00
parent 0ac44c3539
commit ace7d53571
5 changed files with 24 additions and 4 deletions

View File

@@ -31,10 +31,20 @@ Intersect::Intersect()
Intersect::~Intersect()
{
int i;
for(i = 0; i < this->num; i++)
{
free(this->list[i]);
}
/* Free stuff */
free(this->list);
}
void Intersect::reset()
{
this->num = 0;
}
void Intersect::add(Intersection i)
{
Intersection *x;
@@ -46,6 +56,7 @@ void Intersect::add(Intersection i)
stats.addRealloc();
this->list = (Intersection **)realloc(this->list, sizeof(Intersection *) * this->allocated);
}
this->list[this->num++] = new Intersection(i.t, i.object);
stats.setMaxIntersect(this->num);