t_vec2 *new_vec2() {
  t_vec2 *buf;
  buf->size = 2;

  if(!(buf = (t_vec2*)malloc(sizeof(t_vec2))))
    return (0);
  
  if(!(buf->data = (float*)malloc(sizeof(float) * 2))) {
    free(buf);
    return (0);
  }

  return buf;
}

You are trying to dereference buf before allocating memory to it.

  t_vec2 *buf;
  buf->size = 2;

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top