Free intersection t values array after use.
This commit is contained in:
		
							parent
							
								
									99055ff5f4
								
							
						
					
					
						commit
						8b828e45a8
					
				
					 1 changed files with 7 additions and 4 deletions
				
			
		
							
								
								
									
										11
									
								
								src/scene.c
									
										
									
									
									
								
							
							
						
						
									
										11
									
								
								src/scene.c
									
										
									
									
									
								
							| 
						 | 
					@ -157,11 +157,14 @@ scene_trace_ray(Scene *scene, const Ray ray, const int depth)
 | 
				
			||||||
    ObjectList *ptr = scene->objects;
 | 
					    ObjectList *ptr = scene->objects;
 | 
				
			||||||
    while (ptr != NULL) {
 | 
					    while (ptr != NULL) {
 | 
				
			||||||
        nints = object_does_intersect(ptr->object, ray, &t);
 | 
					        nints = object_does_intersect(ptr->object, ray, &t);
 | 
				
			||||||
        for (int i = 0; i < nints; i++) {
 | 
					        if (nints > 0) {
 | 
				
			||||||
            if (t[i] < nearest_t) {
 | 
					            for (int i = 0; i < nints; i++) {
 | 
				
			||||||
                intersected_obj = ptr->object;
 | 
					                if (t[i] < nearest_t) {
 | 
				
			||||||
                nearest_t = t[i];
 | 
					                    intersected_obj = ptr->object;
 | 
				
			||||||
 | 
					                    nearest_t = t[i];
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            free(t);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ptr = ptr->next;
 | 
					        ptr = ptr->next;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue