Hello, I'm writing a ray tracing program and I'm still in the initial stage trying to build a kdtree for the 3d mesh. I have uploaded my code on:

http://www.uploading.com/files/LW2EJYPK/code.zip.html

Out of the four modules, kdtree.c is the only one which is failing at line number 162 ( I found this by using some printf statements and checking values).

kd->child[i]->ntriangles += 1;

Why is this happening ?? My machine is running low on memory at the moment, could it because of that ? Can some one else please verify if this is the problem ?