Advertisement
Guest User

segfault help

a guest
Mar 23rd, 2018
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. void read_objs (OBJ_T **list)
  2. {
  3.   double ctrx, ctry, ctrz, r, R, G, B;
  4.   OBJ_T *node;
  5.   while(scanf("%lf %lf %lf %lf %lf %lf %lf ", &ctrx, &ctry, &ctrz, &r, &R, &G, &B) == 7)
  6.   {
  7.  
  8.     node = (OBJ_T*)malloc(sizeof(OBJ_T));// cast malloc to on
  9.     node->sphere.ctr.x = ctrx;
  10.     node->sphere.ctr.y = ctry;
  11.     node->sphere.ctr.z = ctrz;
  12.     node->sphere.r = r;
  13.     node->color.R = R;
  14.     node->color.G = G;
  15.     node->color.B = B;
  16.  
  17.     node->next = *list;
  18.     //node.next goes to list, list goes to node
  19.     *list = node;
  20.     free(node);
  21.   }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement