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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user