Change the Intersection to a class, and stop using memory allocation for it (and pointer)
A bit more clean (on the code side)
This commit is contained in:
@@ -15,16 +15,16 @@
|
||||
Intersect::Intersect()
|
||||
{
|
||||
this->allocated = MIN_ALLOC;
|
||||
this->list = (Intersection **)calloc(sizeof(Object *), MIN_ALLOC);
|
||||
this->list = (Intersection *)calloc(sizeof(Object *), MIN_ALLOC);
|
||||
this->num = 0;
|
||||
}
|
||||
|
||||
void Intersect::add(Intersection *i)
|
||||
void Intersect::add(Intersection i)
|
||||
{
|
||||
if ((this->num + 1) < this->allocated)
|
||||
{
|
||||
this->allocated *= 2;
|
||||
this->list = (Intersection **)realloc(this->list, sizeof(Object *) * this->allocated);
|
||||
this->list = (Intersection *)realloc(this->list, sizeof(Object *) * this->allocated);
|
||||
}
|
||||
this->list[this->num++] = i;
|
||||
}
|
||||
Reference in New Issue
Block a user