I have googled this problem and looked in R extensions manual, but could find no information on it.
I have a reasonably large program which makes many calls to C code with .C. I am passing in quite a lot of data which doesn't change over the course of the program. I therefore decided to coerce them to the right datatype just once:
vec = as.integer(as.vector(vec)).
Then in the .C call I write:
.C('function', vec = vec)
as opposed to
.C('function', vec = as.integer(as.vector(vec))).
This was done as profiling revealed as.* was taking up a bit of time. However in doing this I get (after a few hundred thousand iterations) a glibc error in malloc:
* glibc detected /usr/lib/R/bin/exec/R: malloc(): memory corruption: 0x0cabc0d8 **
I am just curious as to why this happens, seeing as the object I coerced at the start does not change over the course of the program, and if there is a way to get around this so I can minimise my as.* calls.
Thanks,
Chris