-
malloc HELP
I need help with the syntax for the malloc function, I'm trying to write this code and everything seems to be working fine apart from one warning message. So I've written:
double *a;
double *b;
a = (double*)malloc(s);
b = (double*)malloc(s);
~~
code
~~
free(&a);
free(&b);
s is the number of points. It keeps saying "attempt to free a non heap object". Does anyone know what might be going wrong here?
-
A couple of things, first in C you shouldn't be casting the return value from malloc(), second what is "s"? Third did you look up some documentation for free, pay particular attention to what you're passing to that function, and remember that "a" and "b" are already pointers.